diff --git a/modules/utilities/agenix.nix b/modules/utilities/agenix.nix index 2011d7a..0ca0d21 100644 --- a/modules/utilities/agenix.nix +++ b/modules/utilities/agenix.nix @@ -6,8 +6,11 @@ age.identityPaths = [ "/home/tomasr/.ssh/id_ed25519" ]; - age.secrets.my-secret = { - file = ../../secrets/my-secret.age; + age.secrets.ntfy = { + file = ../../secrets/ntfy.age; + owner = "tomasr"; + group = "users"; + mode = "0400"; }; }; } diff --git a/modules/utilities/autoUpdate.nix b/modules/utilities/autoUpdate.nix index 3c4fa78..290c8a2 100644 --- a/modules/utilities/autoUpdate.nix +++ b/modules/utilities/autoUpdate.nix @@ -1,5 +1,8 @@ {self, ...}: { - flake.nixosModules.autoUpdate-laptop = {pkgs, ...}: { + flake.nixosModules.autoUpdate-laptop = {pkgs, config, ...}: { + age.secrets.ntfy = { + file = ../../secrets/ntfy.age; + }; # Ensure your script is available system-wide environment.systemPackages = [ self.packages.${pkgs.system}.custom-autoupdate-laptop @@ -12,6 +15,9 @@ description = "NixOS flake auto update"; serviceConfig = { + Environment = [ + "NTFY_SECRET=${config.age.secrets.ntfy.path}" + ]; Type = "oneshot"; ExecStart = "/run/current-system/sw/bin/custom-autoupdate"; @@ -98,11 +104,13 @@ runtimeInputs = with pkgs; [ git nixos-rebuild - matrix-commander-rs + curl libnotify ]; text = '' + # shellcheck disable=SC1090 + source "$NTFY_SECRET" set -e FLAKE_DIR="/home/tomasr/nixos" @@ -128,9 +136,11 @@ notify-send "Flake autoupdate" "Rebuild OK" - matrix-commander-rs --verbose -m "Flake rebuild succesfull.
@notificationbot_0000" \ - --html \ - -r "\!BXRRokBmEdNOyYdfOF:matrix.org" + curl \ + -u ":$NTFY_TOKEN" \ + -d "Flake rebuild successful" \ + -H "Title: Flake autoupdate" \ + "$NTFY_SERVER/Alerts" else notify-send "Flake autoupdate" "No changes" git -C "$FLAKE_DIR" push @@ -141,9 +151,12 @@ notify-send -u critical "Flake autoupdate" "FAILED" - matrix-commander-rs --verbose -m "Flake rebuild failed.
Error:
$ERROR_MSG

@notificationbot_0000" \ - --html \ - -r "\!BXRRokBmEdNOyYdfOF:matrix.org" + curl \ + -u ":$NTFY_TOKEN" \ + -d "Flake rebuild failed. Error: $ERROR_MSG" \ + -H "Title: Flake autoupdate FAILED" \ + -H "Priority: urgent" \ + "$NTFY_SERVER/Alerts" git -C "$FLAKE_DIR" reset --hard "pre-autoupdate-$TIME" fi diff --git a/secrets/my-secret.age b/secrets/my-secret.age deleted file mode 100644 index e58b842..0000000 --- a/secrets/my-secret.age +++ /dev/null @@ -1,5 +0,0 @@ -age-encryption.org/v1 --> ssh-ed25519 pcPqbA GG04OY1WKDS1Rc1aRhODZShiWZfdw0cDHN+s/8XqDzA -9/SS7ZOQDh1H+27JT7fTi3GV5C19CjIPR9i4jjKjM9E ---- Irxkq9bamw6q0qsEZHlym6pC0gDxpty+bbg14OAgkxQ -ëĶ‘²ó<…¥ ɨ¬!†K!þ‘L;Ú~´]¶F ñ»Ak‰õwÐy62ϽK