diff --git a/flake.nix b/flake.nix index 4371c51..6f57b01 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ # flake for blakes nixos config # define new devices in outputs -# generation: 374, timestamp: 2025-10-12 18:59:25 +# generation: 375, timestamp: 2025-10-12 19:19:04 { description = "blakes nix config"; inputs = { diff --git a/modules/system/backups.nix b/modules/system/backups.nix index 3675f47..abade99 100644 --- a/modules/system/backups.nix +++ b/modules/system/backups.nix @@ -27,9 +27,6 @@ in default = {}; description = "backup jobs, nested attribute sets should be = paths []"; }; - paths = lib.mkOption { - type = lib.types.list; - }; repo = lib.mkOption { type = lib.types.path; default = "/holocron/borg"; @@ -40,6 +37,11 @@ in default = sec."borg_passwd".path; description = "borg repository passphrase file"; }; + mode = lib.mkOption { + type = lib.types.string; + default = "split"; # "all" + description = "choice between creating one archive of all paths or one archive per service"; + }; }; config = lib.mkIf (cfg.enable && cfg.baks != {}) { @@ -56,7 +58,7 @@ in export BORG_PASSPHRASE="$(cat ${cfg.passwd_file})" export BORG_REPO="${cfg.repo}" timestamp="$(date +'%Y-%m-%d_%H:%M:%S')" - mode=sep + mode=${cfg.mode} # init repo in needed if ! borg info "$BORG_REPO" >/dev/null 2>&1; then @@ -68,7 +70,7 @@ in echo "starting backup at $timestamp" - if [ "$mode" = "sep" ]; then + if [ "$mode" = "split" ]; then # loop for each backup ${lib.concatStringsSep "\n\n" (lib.mapAttrsToList (bak_name: bak_paths: '' @@ -91,9 +93,9 @@ in --keep-weekly=52 \ --keep-monthly=-1 echo "backup run complete at \"$BORG_REPO::$archive\"" - exit 0 '' ) cfg.baks)} + exit 0 else # flatten all paths from cfg.baks into one big list all_paths="${