add enable option for backup modules
This commit is contained in:
parent
cb7fb66ee2
commit
7a30f6bde8
2 changed files with 8 additions and 5 deletions
|
@ -4,6 +4,8 @@ let
|
||||||
cfg = config.shb.backup;
|
cfg = config.shb.backup;
|
||||||
|
|
||||||
instanceOptions = {
|
instanceOptions = {
|
||||||
|
enable = lib.mkEnableOption "shb backup instance";
|
||||||
|
|
||||||
backend = lib.mkOption {
|
backend = lib.mkOption {
|
||||||
description = "What program to use to make the backups.";
|
description = "What program to use to make the backups.";
|
||||||
type = lib.types.enum [ "borgmatic" "restic" ];
|
type = lib.types.enum [ "borgmatic" "restic" ];
|
||||||
|
@ -130,8 +132,9 @@ in
|
||||||
|
|
||||||
config = lib.mkIf (cfg.instances != {}) (
|
config = lib.mkIf (cfg.instances != {}) (
|
||||||
let
|
let
|
||||||
borgmaticInstances = lib.attrsets.filterAttrs (k: i: i.backend == "borgmatic") cfg.instances;
|
enabledInstances = lib.attrsets.filterAttrs (k: i: i.enable) cfg.instances;
|
||||||
resticInstances = lib.attrsets.filterAttrs (k: i: i.backend == "restic") cfg.instances;
|
borgmaticInstances = lib.attrsets.filterAttrs (k: i: i.backend == "borgmatic") enabledInstances;
|
||||||
|
resticInstances = lib.attrsets.filterAttrs (k: i: i.backend == "restic") enabledInstances;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
users.users = {
|
users.users = {
|
||||||
|
@ -180,7 +183,7 @@ in
|
||||||
}) instance.repositories))
|
}) instance.repositories))
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
lib.mkMerge (lib.flatten (lib.attrsets.mapAttrsToList mkSopsSecret cfg.instances));
|
lib.mkMerge (lib.flatten (lib.attrsets.mapAttrsToList mkSopsSecret enabledInstances));
|
||||||
|
|
||||||
systemd.timers.borgmatic = lib.mkIf (borgmaticInstances != {}) {
|
systemd.timers.borgmatic = lib.mkIf (borgmaticInstances != {}) {
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
|
@ -196,7 +199,7 @@ in
|
||||||
ExecStart = [ "" "${pkgs.borgmatic}/bin/borgmatic --verbosity -1 --syslog-verbosity 1" ];
|
ExecStart = [ "" "${pkgs.borgmatic}/bin/borgmatic --verbosity -1 --syslog-verbosity 1" ];
|
||||||
# For borgmatic, since we have only one service, we need to merge all environmentFile
|
# For borgmatic, since we have only one service, we need to merge all environmentFile
|
||||||
# from all instances.
|
# from all instances.
|
||||||
EnvironmentFile = lib.mapAttrsToList (name: value: value.environmentFile) cfg.instances;
|
EnvironmentFile = lib.mapAttrsToList (name: value: value.environmentFile) enabledInstances;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,6 @@ in
|
||||||
mountConfig.TimeoutSet = 15;
|
mountConfig.TimeoutSet = 15;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
lib.debug.traceValSeqN 2 (map mkMountCfg cfg.mounts);
|
map mkMountCfg cfg.mounts;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue