54 lines
1.6 KiB
Nix
54 lines
1.6 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) mkEnableOption mkOption mkPackageOption mkIf types;
|
|
cfg = config.programs.resticprofile;
|
|
yamlFormat = pkgs.formats.yaml { };
|
|
in {
|
|
options.programs.resticprofile = {
|
|
enable = mkEnableOption "Enable resticprofile (Restic backup profile manager)";
|
|
|
|
package = mkPackageOption pkgs "resticprofile" { };
|
|
|
|
# Multiple configuration files support
|
|
profiles = mkOption {
|
|
type = types.attrsOf yamlFormat.type;
|
|
default = { };
|
|
description = ''
|
|
Multiple configuration files for resticprofile. Each attribute name
|
|
becomes a YAML file under `$XDG_CONFIG_HOME/resticprofile/`.
|
|
This allows creating multiple files that can reference each other.
|
|
The contents of each profile will be merged with the base profile using `lib.mkMerge`.
|
|
'';
|
|
example = {
|
|
common = {
|
|
repository = "local:/backup";
|
|
passwordFile = "password.txt";
|
|
includes = [ "common.yaml" ];
|
|
backup = {
|
|
source = [ "/home/user/Documents" ];
|
|
schedule = "12:30";
|
|
};
|
|
forget = {
|
|
keep-daily = 7;
|
|
keep-weekly = 4;
|
|
keep-monthly = 6;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [ cfg.package ];
|
|
xdg.configFile."resticprofile/profiles.yaml".source =
|
|
let
|
|
baseProfile = import ./resticprofile-base.nix { inherit lib; };
|
|
in
|
|
yamlFormat.generate "profiles" (lib.mkMerge [
|
|
baseProfile
|
|
cfg.profiles
|
|
]);
|
|
};
|
|
}
|