update backup.info rendering

This commit is contained in:
Ingolf Wagner 2025-06-16 12:13:58 +02:00
parent 3e2602aad5
commit 5a3b9dd8cf

View file

@ -10,7 +10,7 @@ with types;
options.backup = {
dirs = mkOption {
type = listOf string;
type = listOf str;
default = [ ];
description = ''
List of all folders that should be backed up.
@ -21,17 +21,44 @@ with types;
"/home/palo/.gnupg"
];
};
configurations = mkOption {
type = listOf str;
default = [ ];
description = ''
Add your backup system here, which takes care of backuping files in `backup.dir`.
'';
example = [
"restic"
"borgbackup"
];
};
};
config = lib.mkMerge [
(lib.mkIf (config.backup.dirs != [ ]) {
home.file."backup.info".text = ''
home.file."backup.info".text =
let
backupList = concatStringsSep "\n" (map (path: "- ${path}") (sort lessThan config.backup.dirs));
configurationsList = concatStringsSep "\n" (
map (backupSystem: "- ${backupSystem}") config.backup.configurations
);
Backup is not configured yet, but these folders need
to be backed up if you set one up.
emptyHeader = ''
Backup is not configured yet, these folders need
to be backed up if you set one up.'';
${concatStringsSep "\n" (map (path: "- ${path}") (sort lessThan config.backup.dirs))}
'';
fullHeader = ''
Backup is configured with
${configurationsList}
These are the folders which are backuped up'';
header = if (config.backup.configurations == [ ]) then emptyHeader else fullHeader;
in
''
${header}
${backupList}
'';
})
];
}