From 2104608642f3be6671ace4d6d9b29837cbf4ad2b Mon Sep 17 00:00:00 2001 From: Winter Date: Sat, 8 Jan 2022 17:45:07 -0500 Subject: nixos/borgbackup: allow empty archive base name --- nixos/modules/services/backup/borgbackup.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'nixos/modules/services/backup') diff --git a/nixos/modules/services/backup/borgbackup.nix b/nixos/modules/services/backup/borgbackup.nix index 220c571b927e5..6804055a2940a 100644 --- a/nixos/modules/services/backup/borgbackup.nix +++ b/nixos/modules/services/backup/borgbackup.nix @@ -30,7 +30,7 @@ let } trap 'on_exit' INT TERM QUIT EXIT - archiveName="${cfg.archiveBaseName}-$(date ${cfg.dateFormat})" + archiveName="${if cfg.archiveBaseName == null then "" else cfg.archiveBaseName + "-"}$(date ${cfg.dateFormat})" archiveSuffix="${optionalString cfg.appendFailedSuffix ".failed"}" ${cfg.preHook} '' + optionalString cfg.doInit '' @@ -60,7 +60,7 @@ let '' + optionalString (cfg.prune.keep != { }) '' borg prune $extraArgs \ ${mkKeepArgs cfg} \ - --prefix ${escapeShellArg cfg.prune.prefix} \ + ${optionalString (cfg.prune.prefix != null) "--prefix ${escapeShellArg cfg.prune.prefix} \\"} $extraPruneArgs ${cfg.postPrune} ''; @@ -284,7 +284,7 @@ in { }; archiveBaseName = mkOption { - type = types.strMatching "[^/{}]+"; + type = types.nullOr (types.strMatching "[^/{}]+"); default = "${globalConfig.networking.hostName}-${name}"; defaultText = literalExpression ''"''${config.networking.hostName}-"''; description = '' @@ -292,6 +292,7 @@ in { determined by , will be appended. The full name can be modified at runtime ($archiveName). Placeholders like {hostname} must not be used. + Use null for no base name. ''; }; @@ -471,11 +472,11 @@ in { }; prune.prefix = mkOption { - type = types.str; + type = types.nullOr (types.str); description = '' Only consider archive names starting with this prefix for pruning. By default, only archives created by this job are considered. - Use "" to consider all archives. + Use "" or null to consider all archives. ''; default = config.archiveBaseName; defaultText = literalExpression "archiveBaseName"; -- cgit 1.4.1