Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
oluceps committed Oct 19, 2024
1 parent 3798a93 commit d6d536b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
9 changes: 4 additions & 5 deletions hosts/hastur/backup.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down
12 changes: 0 additions & 12 deletions hosts/kaambl/backup.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
# };
# };
};
};
}
20 changes: 10 additions & 10 deletions modules/rustic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let
cfg = config.services.rustic;
inherit (lib)
mkOption
listToAttrs
foldl'
types
removeSuffix
Expand All @@ -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);
Expand All @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit d6d536b

Please sign in to comment.