homelab framework module init (everything is a mess)
This commit is contained in:
parent
0347f4d325
commit
bcbcc8b17b
94 changed files with 7289 additions and 436 deletions
95
modules/nixos/system/backups/backups-option.nix
Normal file
95
modules/nixos/system/backups/backups-option.nix
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
# backups-option.nix
|
||||
cfg: let
|
||||
inherit (cfg.lib) mkOption types mkEnableOption attrNames;
|
||||
in
|
||||
mkOption {
|
||||
type = types.attrsOf (
|
||||
types.submodule (
|
||||
{
|
||||
name,
|
||||
config,
|
||||
...
|
||||
} @ args: {
|
||||
options = {
|
||||
backend = mkOption {
|
||||
type = types.enum (attrNames cfg.backends);
|
||||
description = "The backup backend to use";
|
||||
};
|
||||
|
||||
paths = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "Paths to backup";
|
||||
};
|
||||
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to enable this backup job";
|
||||
};
|
||||
|
||||
timerConfig = mkOption {
|
||||
type = with types; nullOr attrs;
|
||||
default = null;
|
||||
example = {
|
||||
OnCalendar = "00:05";
|
||||
Persistent = true;
|
||||
RandomizedDelaySec = "5h";
|
||||
};
|
||||
description = ''
|
||||
When to run the backup. If null, inherits from backend's default timerConfig.
|
||||
Set to null to disable automatic scheduling.
|
||||
'';
|
||||
};
|
||||
|
||||
backendOptions = mkOption {
|
||||
type = let
|
||||
backupConfig = config;
|
||||
backupName = name;
|
||||
in
|
||||
types.submodule (
|
||||
{config, ...} @ args'':
|
||||
cfg.backends.${args.config.backend} (args'' // {inherit backupConfig backupName;})
|
||||
);
|
||||
default = {};
|
||||
description = "Backend-specific options";
|
||||
};
|
||||
|
||||
preBackupScript = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = "Script to run before backing up";
|
||||
};
|
||||
|
||||
postBackupScript = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Script to run after backing up. Runs even if the backup fails.
|
||||
'';
|
||||
};
|
||||
|
||||
notifications = {
|
||||
failure = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Enable failure notifications";
|
||||
};
|
||||
};
|
||||
|
||||
success = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable success notifications";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = {};
|
||||
description = "Backup job definitions";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue