52 lines
1.5 KiB
Nix
52 lines
1.5 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}: let
|
|
readlink = "${pkgs.coreutils}/bin/readlink";
|
|
notify-send = "${pkgs.libnotify}/bin/notify-send";
|
|
in {
|
|
systemd = {
|
|
services = {
|
|
NetworkManager-wait-online.enable = lib.mkForce false;
|
|
systemd-networkd-wait-online.enable = lib.mkForce false;
|
|
clean-keychain = {
|
|
description = "Clean up .keychain on boot";
|
|
wantedBy = ["multi-user.target"];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
ExecStart = "${pkgs.coreutils-full}/bin/rm -rf /home/don/.keychain";
|
|
};
|
|
};
|
|
};
|
|
user = {
|
|
services = {
|
|
detect-reboot-for-upgrade = {
|
|
script = ''
|
|
set -eu -o pipefail
|
|
booted="$(${readlink} /run/booted-system/{initrd,kernel,kernel-modules})"
|
|
built="$(${readlink} /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
|
|
if [[ "''${booted}" != "''${built}" ]];
|
|
then
|
|
echo "Looks like we need a reboot!"
|
|
${notify-send} --urgency=low --icon=system-reboot "Reboot is needed for a NixOS upgrade."
|
|
fi
|
|
'';
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
};
|
|
};
|
|
};
|
|
timers = {
|
|
detect-reboot-for-upgrade = {
|
|
wantedBy = ["timers.target"];
|
|
partOf = ["detect-reboot-for-upgrade.service"];
|
|
timerConfig = {
|
|
OnCalendar = "hourly";
|
|
Unit = "detect-reboot-for-upgrade.service";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|