commit 26e2e7cf54e5b75015ee2fe8ce81298e5b2e9460
parent 128e983e3290edac02bc9a9293b50023de06a533
Author: Katja (zaphyra) <git@ctu.cx>
Date: Thu, 29 May 2025 23:50:12 +0200
parent 128e983e3290edac02bc9a9293b50023de06a533
Author: Katja (zaphyra) <git@ctu.cx>
Date: Thu, 29 May 2025 23:50:12 +0200
config/nixos/modules/services/resticBackup: support `environmentFile`
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/config/nixos/modules/services/resticBackup.nix b/config/nixos/modules/services/resticBackup.nix @@ -43,6 +43,10 @@ in type = types.str; default = "root"; }; + environmentFile = lib.mkOption { + type = with types; nullOr str; + default = null; + }; passwordFile = lib.mkOption { type = types.str; }; @@ -84,6 +88,34 @@ in }; config = lib.mkIf (cfg.paths != { }) { + + systemd.services = ( + cfg.paths + |> lib.attrsToList + |> lib.map ( + element: + ( + if element.value.enable then + ( + element.value.targets + |> lib.map ( + target: + lib.nameValuePair "restic-backups-${element.name}-${target}" { + serviceConfig.EnvironmentFile = [ + cfg.targets."${target}".environmentFile + element.value.environmentFile + ]; + } + ) + ) + else + [ ] + ) + ) + |> lib.flatten + |> lib.listToAttrs + ); + services.restic.backups = ( cfg.paths |> lib.attrsToList @@ -101,7 +133,6 @@ in passwordFile = element.value.passwordFile; timerConfig = element.value.timerConfig; repository = cfg.targets."${target}".repository + "/${config.networking.hostName}-${element.name}"; - environmentFile = cfg.targets."${target}".environmentFile; paths = lib.mkMerge [ element.value.paths (lib.mkIf (element.value.postgresDatabases != [ ]) (