From cd99b128d4472148e64c88e2d0bbcf8acd277ed0 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Fri, 29 Nov 2024 17:04:24 +0100 Subject: [PATCH] feat: add preStart hook for nixos-upgrade service Introduce a preStart hook to the nixos-upgrade systemd service to ensure the local repository is updated before upgrades by fetching and resetting to the origin's HEAD. This enhances the reliability and consistency of the upgrade process. Also, maintain the commented out old flake path for backward traceability. --- systems/x86_64-linux/mx/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/systems/x86_64-linux/mx/default.nix b/systems/x86_64-linux/mx/default.nix index 8adc226..9d68b5f 100644 --- a/systems/x86_64-linux/mx/default.nix +++ b/systems/x86_64-linux/mx/default.nix @@ -37,10 +37,18 @@ dates = "04:00"; operation = "switch"; allowReboot = true; -# flake = lib.mkForce "git+file:///var/lib/gitea/repositories/harald/nixcfg.git#mx"; + # flake = lib.mkForce "git+file:///var/lib/gitea/repositories/harald/nixcfg.git#mx"; flake = lib.mkForce "/root/nixcfg/.#mx"; }; + systemd.services.nixos-upgrade = { + preStart = '' + cd /root + git fetch origin + git reset --hard origin/HEAD + ''; + }; + nix.gc = { dates = "daily"; options = "--delete-older-than 7d";