From 7e5d13ac3dbfabf1ee4946196456becf3e329fd9 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sun, 27 Jul 2025 19:36:40 +0200 Subject: [PATCH] treewide: fmt --- modules/services/backup/default.nix | 50 ++++++++++---------- modules/services/blocky/default.nix | 3 +- modules/services/hedgedoc/default.nix | 3 +- modules/services/home-automation/default.nix | 3 +- modules/services/paperless/default.nix | 3 +- modules/services/photos/default.nix | 3 +- 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/modules/services/backup/default.nix b/modules/services/backup/default.nix index 8b78db5..f13612f 100644 --- a/modules/services/backup/default.nix +++ b/modules/services/backup/default.nix @@ -126,7 +126,8 @@ in "/data/todo" "/home/*/tmp" "/home/*/todo" - ] ++ cfg.exclude; + ] + ++ cfg.exclude; extraCreateArgs = [ "--exclude-caches" @@ -145,31 +146,30 @@ in inherit (cfg) doInit; compression = "auto,zstd"; - postHook = - '' - if (( $exitStatus > 1 )); then - '' - + lib.optionalString cfg.OnFailureNotification '' - # iterate over all logged in users - for user in $(users); do - sway_pid=$(${pkgs.procps}/bin/pgrep -x "sway" -u "$user") - if [ -n "$sway_pid" ]; then - # set environment variables - export $(cat /proc/$sway_pid/environ | grep -z '^DBUS_SESSION_BUS_ADDRESS=' | tr -d '\0') - export DISPLAY=:0 - # send notification via dbus: https://wiki.archlinux.org/title/Desktop_notifications#Bash - ${lib.getExe pkgs.sudo} --preserve-env=DBUS_SESSION_BUS_ADDRESS,DISPLAY -u $user ${lib.getExe pkgs.libnotify} -u critical "BorgBackup Failed!" "Run journalctl -u borgbackup-job* for more details." - echo "sent notification" - fi - done - '' - + lib.optionalString (cfg.OnFailureMail != null) '' - journalctl -u borgbackup-job-hetzner.service --since "5 days ago" | ${pkgs.mailutils}/bin/mail -r "Administrator" -s "Backup Error" server@buehler.rocks - echo "sent mail" - '' - + '' + postHook = '' + if (( $exitStatus > 1 )); then + '' + + lib.optionalString cfg.OnFailureNotification '' + # iterate over all logged in users + for user in $(users); do + sway_pid=$(${pkgs.procps}/bin/pgrep -x "sway" -u "$user") + if [ -n "$sway_pid" ]; then + # set environment variables + export $(cat /proc/$sway_pid/environ | grep -z '^DBUS_SESSION_BUS_ADDRESS=' | tr -d '\0') + export DISPLAY=:0 + # send notification via dbus: https://wiki.archlinux.org/title/Desktop_notifications#Bash + ${lib.getExe pkgs.sudo} --preserve-env=DBUS_SESSION_BUS_ADDRESS,DISPLAY -u $user ${lib.getExe pkgs.libnotify} -u critical "BorgBackup Failed!" "Run journalctl -u borgbackup-job* for more details." + echo "sent notification" fi - ''; + done + '' + + lib.optionalString (cfg.OnFailureMail != null) '' + journalctl -u borgbackup-job-hetzner.service --since "5 days ago" | ${pkgs.mailutils}/bin/mail -r "Administrator" -s "Backup Error" server@buehler.rocks + echo "sent mail" + '' + + '' + fi + ''; # for mail sending readWritePaths = lib.optional (cfg.OnFailureMail != null) "/var/lib/postfix/queue/maildrop/"; diff --git a/modules/services/blocky/default.nix b/modules/services/blocky/default.nix index 8c23f84..f5e336b 100644 --- a/modules/services/blocky/default.nix +++ b/modules/services/blocky/default.nix @@ -49,7 +49,8 @@ in ]; }; prometheus.enable = config.services.prometheus.enable; - } // cfg.settings; + } + // cfg.settings; }; prometheus.scrapeConfigs = [ diff --git a/modules/services/hedgedoc/default.nix b/modules/services/hedgedoc/default.nix index 11ad8b6..9510604 100644 --- a/modules/services/hedgedoc/default.nix +++ b/modules/services/hedgedoc/default.nix @@ -41,7 +41,8 @@ in dialect = "sqlite"; storage = "/var/lib/hedgedoc/hedgedoc.sqlite"; }; - } // cfg.settings; + } + // cfg.settings; }; prometheus = { diff --git a/modules/services/home-automation/default.nix b/modules/services/home-automation/default.nix index e39ec2c..9164cff 100644 --- a/modules/services/home-automation/default.nix +++ b/modules/services/home-automation/default.nix @@ -108,7 +108,8 @@ in "esphome" "shelly" "prometheus" - ] ++ cfg.extraComponents; + ] + ++ cfg.extraComponents; }; prometheus.scrapeConfigs = [ diff --git a/modules/services/paperless/default.nix b/modules/services/paperless/default.nix index 208ad6b..e7e231c 100644 --- a/modules/services/paperless/default.nix +++ b/modules/services/paperless/default.nix @@ -33,7 +33,8 @@ in inherit (cfg) mediaDir passwordFile; settings = { PAPERLESS_OCR_LANGUAGE = "deu+eng"; - } // cfg.settings; + } + // cfg.settings; }; # monitoring is not really useful, because it only contains the http-worker infos -> skipped for now diff --git a/modules/services/photos/default.nix b/modules/services/photos/default.nix index 0c31d53..e062986 100644 --- a/modules/services/photos/default.nix +++ b/modules/services/photos/default.nix @@ -43,7 +43,8 @@ in settings = { ffmpeg.transcode = "disabled"; server.externalDomain = "https://photos.${domain}"; - } // cfg.settings; + } + // cfg.settings; environment = { IMMICH_TELEMETRY_INCLUDE = "all"; IMMICH_API_METRICS_PORT = toString (port + 1);