massicot,fix: fix missing module
This commit is contained in:
parent
5104c5943e
commit
6b375fea91
5 changed files with 33 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
|||
# TODO: https://github.com/lilyinstarlight/foosteros/blob/dfe1ab3eb68bfebfaa709482d52fa04ebdde81c8/config/restic.nix#L23 <- this is better
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
@ -11,6 +11,14 @@ in
|
|||
options = {
|
||||
custom.restic = {
|
||||
enable = lib.mkEnableOption "restic";
|
||||
paths = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [
|
||||
"/home"
|
||||
"/var/lib"
|
||||
];
|
||||
};
|
||||
prune = lib.mkEnableOption "auto prune remote restic repo";
|
||||
repositoryFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
|
@ -22,14 +30,10 @@ in
|
|||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.restic.backups = {
|
||||
remotebackup = {
|
||||
services.restic.backups.${config.networking.hostName} = lib.mkMerge [
|
||||
{
|
||||
repositoryFile = cfg.repositoryFile;
|
||||
passwordFile = cfg.passwordFile;
|
||||
paths = [
|
||||
"/home"
|
||||
"/var/lib"
|
||||
];
|
||||
exclude = [
|
||||
"/home/*/.cache"
|
||||
"/home/*/.cargo"
|
||||
|
@ -40,13 +44,24 @@ in
|
|||
OnCalendar = "00:05";
|
||||
RandomizedDelaySec = "5h";
|
||||
};
|
||||
pruneOpts = [
|
||||
pruneOpts = lib.mkIf cfg.prune [
|
||||
"--keep-daily 7"
|
||||
"--keep-weekly 5"
|
||||
"--keep-monthly 12"
|
||||
"--keep-yearly 75"
|
||||
];
|
||||
};
|
||||
};
|
||||
paths = lib.mkDefault cfg.paths;
|
||||
initialize = true;
|
||||
}
|
||||
(lib.mkIf (config.fileSystems."/".fsType == "btrfs") {
|
||||
backupPrepareCommand = ''
|
||||
btrfs subvolume snapshot -r / backup
|
||||
'';
|
||||
backupCleanupCommand = ''
|
||||
btrfs subvolume delete /backup
|
||||
'';
|
||||
paths = map (p: "/backup" + p) cfg.paths;
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue