Merge pull request #154061 from winterqt/borgbackup-empty-archive-base-name

nixos/borgbackup: allow empty archive base name

authored by pennae and committed by GitHub 4a44a5f1 cf3c3da4

+6 -5
+6 -5
nixos/modules/services/backup/borgbackup.nix
··· 30 30 } 31 31 trap 'on_exit' INT TERM QUIT EXIT 32 32 33 - archiveName="${cfg.archiveBaseName}-$(date ${cfg.dateFormat})" 33 + archiveName="${if cfg.archiveBaseName == null then "" else cfg.archiveBaseName + "-"}$(date ${cfg.dateFormat})" 34 34 archiveSuffix="${optionalString cfg.appendFailedSuffix ".failed"}" 35 35 ${cfg.preHook} 36 36 '' + optionalString cfg.doInit '' ··· 60 60 '' + optionalString (cfg.prune.keep != { }) '' 61 61 borg prune $extraArgs \ 62 62 ${mkKeepArgs cfg} \ 63 - --prefix ${escapeShellArg cfg.prune.prefix} \ 63 + ${optionalString (cfg.prune.prefix != null) "--prefix ${escapeShellArg cfg.prune.prefix} \\"} 64 64 $extraPruneArgs 65 65 ${cfg.postPrune} 66 66 ''; ··· 284 284 }; 285 285 286 286 archiveBaseName = mkOption { 287 - type = types.strMatching "[^/{}]+"; 287 + type = types.nullOr (types.strMatching "[^/{}]+"); 288 288 default = "${globalConfig.networking.hostName}-${name}"; 289 289 defaultText = literalExpression ''"''${config.networking.hostName}-<name>"''; 290 290 description = '' ··· 292 292 determined by <option>dateFormat</option>, will be appended. The full 293 293 name can be modified at runtime (<literal>$archiveName</literal>). 294 294 Placeholders like <literal>{hostname}</literal> must not be used. 295 + Use <literal>null</literal> for no base name. 295 296 ''; 296 297 }; 297 298 ··· 471 472 }; 472 473 473 474 prune.prefix = mkOption { 474 - type = types.str; 475 + type = types.nullOr (types.str); 475 476 description = '' 476 477 Only consider archive names starting with this prefix for pruning. 477 478 By default, only archives created by this job are considered. 478 - Use <literal>""</literal> to consider all archives. 479 + Use <literal>""</literal> or <literal>null</literal> to consider all archives. 479 480 ''; 480 481 default = config.archiveBaseName; 481 482 defaultText = literalExpression "archiveBaseName";