From a4b0edf7f047a5dea5b93cdb4ba382d59482ac6a Mon Sep 17 00:00:00 2001 From: fruchti Date: Sun, 12 Mar 2023 12:55:11 +0100 Subject: [PATCH] Disco: Wake up system for auto-upgrades --- hosts/Disco.nix | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/hosts/Disco.nix b/hosts/Disco.nix index c90290d..3af4ef5 100644 --- a/hosts/Disco.nix +++ b/hosts/Disco.nix @@ -124,7 +124,6 @@ in "steam-run" ]; - fileSystems."/windows" = { device = "/dev/disk/by-uuid/C61C2B5E1C2B492F"; fsType = "ntfs"; @@ -142,6 +141,35 @@ in }; }; + system.autoUpgrade = { + enable = true; + allowReboot = false; + sendEmail = true; + gitPull = true; + gitUser = "fruchti"; + }; + systemd.timers.nixos-upgrade = { + timerConfig = { + WakeSystem = true; + }; + }; + systemd.services.nixos-upgrade = let + updateScript = (pkgs.writeShellScriptBin "nixos-upgrade" '' + set -e + ${config.systemd.services.nixos-upgrade.script} + ''); + in { + unitConfig = { + ConditionACPower = true; + Requires = [ "network-online.target" ]; + }; + serviceConfig = { + # Workaround for https://github.com/systemd/systemd/issues/14045 + ExecStartPre = "${pkgs.coreutils}/bin/sleep 10s"; + ExecStart = lib.mkForce "systemd-inhibit --what=sleep --mode=delay --why='NixOS upgrade' ${updateScript}/bin/nixos-upgrade"; + }; + }; + # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions # on your system were taken. It‘s perfectly fine and recommended to leave