summaryrefslogtreecommitdiff
path: root/modules/auto-update.nix
diff options
context:
space:
mode:
authorGrace Yoder <grace_yoder@outlook.com>2026-10-02 14:22:35 -0400
committerGrace Yoder <grace_yoder@outlook.com>2026-10-02 21:50:15 -0400
commita726e22695ada34a3981040ff0175574050fc995 (patch)
tree3f2edddfcbb8ee9c23dd295463188a17b230204c /modules/auto-update.nix
parenta2c6dcc045a2e5bfd51f1b8f9569d1149202cb67 (diff)
hamano stuff
Diffstat (limited to 'modules/auto-update.nix')
-rw-r--r--modules/auto-update.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/auto-update.nix b/modules/auto-update.nix
new file mode 100644
index 0000000..b370390
--- /dev/null
+++ b/modules/auto-update.nix
@@ -0,0 +1,26 @@
+{ pkgs, ... }:
+
+{
+ system.autoUpgrade = {
+ enable = true;
+ dates = "minutely";
+ allowReboot = true;
+ upgrade = false;
+ };
+
+ systemd.services.nixos-upgrade = {
+ path = [ pkgs.git ];
+ serviceConfig = {
+ WorkingDirectory = "/etc/nixos";
+ StateDirectory = "nixos-repo-update";
+ ExecCondition = pkgs.writeShellScript "check-nixos-repo" ''
+ set -euo pipefail
+ git fetch || exit 255
+ test "$(cat "$STATE_DIRECTORY/applied" 2>/dev/null || true)" != "$(git rev-parse '@{upstream}')"
+ '';
+ };
+
+ preStart = "git pull --ff-only";
+ postStart = ''git rev-parse HEAD > "$STATE_DIRECTORY/applied"'';
+ };
+}