From f6a4f0994c356a039f10029cb0f36cd1aeece401 Mon Sep 17 00:00:00 2001 From: Tasia Iso Date: Fri, 24 May 2024 12:51:50 +0200 Subject: [PATCH] autoupgrade --- common/services/autoupgrade.nix | 34 +++++++++++++++++++++++++++++++++ hosts/yaseen/configuration.nix | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 common/services/autoupgrade.nix diff --git a/common/services/autoupgrade.nix b/common/services/autoupgrade.nix new file mode 100644 index 0000000..0ba8b54 --- /dev/null +++ b/common/services/autoupgrade.nix @@ -0,0 +1,34 @@ +{ + pkgs, + ... +}:{ + # systemd.timers."nix-auto-upgrade" = { + # wantedBy = ["timers.target"]; + # timerConfig = { + # OnCalendar = "weekly"; + # Persistent = true; + # Unit = "nix-auto-upgrade"; + # }; + # }; + + systemd.services."nix-auto-upgrade" = { + script = '' + set -eu + + ${pkgs.git}/bin/git pull && \ + ${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --flake .#$(cat /etc/hostname) + + ${pkgs.curl}/bin/curl \ + -H "Title: NixOS upgrade done" \ + -H "Priority: low" \ + -H "Tags: low" \ + -d "$(cat /etc/hostname ): upgrade script done" \ + ntfy.sh/tasiaiso_upgrades &> /dev/null # Please don't make me learn how to manage secrets + ''; + serviceConfig = { + Type = "oneshot"; + User = "root"; + WorkingDirectory = /etc/nixos/nixos-config; + }; + }; +} \ No newline at end of file diff --git a/hosts/yaseen/configuration.nix b/hosts/yaseen/configuration.nix index 3929d80..14bade9 100644 --- a/hosts/yaseen/configuration.nix +++ b/hosts/yaseen/configuration.nix @@ -33,6 +33,8 @@ in { ../../common/services/adguardhome.nix ../../common/services/syncthing.nix ../../common/services/usbguard.nix + + ../../common/services/autoupgrade.nix ../../modules/nixos/vedirect-reader.nix