diff --git a/hosts/hastur/backup.nix b/hosts/hastur/backup.nix index b69cea82..3b9a063d 100644 --- a/hosts/hastur/backup.nix +++ b/hosts/hastur/backup.nix @@ -3,10 +3,10 @@ services.rustic = { backups = { critic = { - profiles = lib.genAttrs [ + profiles = map (n: config.age.secrets.${n}.path) [ "general.toml" "on-kaambl.toml" - ] (n: config.age.secrets.${n}.path); + ]; timerConfig = { OnCalendar = "*-*-* 2,14:00:00"; @@ -16,11 +16,10 @@ }; }; solid = { - profiles = lib.genAttrs [ + profiles = map (n: config.age.secrets.${n}.path) [ "general.toml" "on-eihort.toml" - ] (n: config.age.secrets.${n}.path); - + ]; timerConfig = { OnCalendar = "*-*-* 3,15:00:00"; RandomizedDelaySec = "4h"; diff --git a/hosts/kaambl/backup.nix b/hosts/kaambl/backup.nix index 0b396256..35a92fb5 100644 --- a/hosts/kaambl/backup.nix +++ b/hosts/kaambl/backup.nix @@ -2,19 +2,7 @@ { services.rustic = { backups = { - # solid = { - # profiles = lib.genAttrs [ - # "general.toml" - # "on-eihort.toml" - # ] (n: config.age.secrets.${n}.path); - # timerConfig = { - # OnCalendar = "*-*-* 3,15:00:00"; - # RandomizedDelaySec = "4h"; - # FixedRandomDelay = true; - # Persistent = true; - # }; - # }; }; }; } diff --git a/modules/rustic.nix b/modules/rustic.nix index 94fc7a7d..18dda69d 100644 --- a/modules/rustic.nix +++ b/modules/rustic.nix @@ -9,6 +9,7 @@ let cfg = config.services.rustic; inherit (lib) mkOption + listToAttrs foldl' types removeSuffix @@ -33,9 +34,9 @@ in options = { package = mkPackageOption pkgs "rustic" { }; profiles = mkOption { - type = with types; attrsOf str; - default = { }; - description = "profiles file = path"; + type = with types; listOf str; + default = [ ]; + description = "profiles file path"; }; timerConfig = mkOption { type = types.nullOr (types.attrsOf unitOption); @@ -62,12 +63,11 @@ in }; config = mkIf (cfg.backups != [ ]) { environment.systemPackages = [ pkgs.rustic ]; - environment.etc = mapAttrs' (name: path: { - name = "rustic/" + name; - value = { - source = path; - }; - }) (foldl' (acc: i: acc // i.profiles) { } (attrValues cfg.backups)); + environment.etc = listToAttrs ( + map (n: nameValuePair ("rustic/" + removeSuffix ".toml" (baseNameOf n)) { source = n; }) ( + foldl' (acc: i: acc ++ i.profiles) [ ] (attrValues cfg.backups) + ) + ); systemd.services = mapAttrs' ( name: opts: @@ -91,7 +91,7 @@ in ExecStart = let profileArgs = lib.concatStringsSep " " ( - map (i: "-P ${removeSuffix ".toml" i}") (attrNames opts.profiles) + map (i: "-P ${removeSuffix ".toml" (baseNameOf i)}") (opts.profiles) ); baseCmd = (lib.getExe' opts.package "rustic") + " " + profileArgs; in