workstation/detect-reboot-needed.nix | add new service to nag when reboot needed
This commit is contained in:
parent
8b9a639b7f
commit
839b74b3bf
2 changed files with 31 additions and 0 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
/etc/nixos/hardware-configuration.nix
|
/etc/nixos/hardware-configuration.nix
|
||||||
/home/don/nixos/workstation/configuration.nix
|
/home/don/nixos/workstation/configuration.nix
|
||||||
/home/don/nixos/workstation/sway.nix
|
/home/don/nixos/workstation/sway.nix
|
||||||
|
/home/don/nixos/workstation/detect-reboot-needed.nix
|
||||||
];
|
];
|
||||||
networking.hostName = "loki";
|
networking.hostName = "loki";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
workstation/detect-reboot-needed.nix
Normal file
30
workstation/detect-reboot-needed.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
readlink = "${pkgs.coreutils}/bin/readlink";
|
||||||
|
notify-send = "${pkgs.libnotify}/bin/notify-send";
|
||||||
|
in {
|
||||||
|
systemd.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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
systemd.user.timers.detect-reboot-for-upgrade = {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
partOf = [ "detect-reboot-for-upgrade.service" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "hourly";
|
||||||
|
Unit = "detect-reboot-for-upgrade.service";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue