50 lines
1.4 KiB
Nix
50 lines
1.4 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) mkEnableOption mkOption mkPackageOption mkIf types;
|
|
cfg = config.programs.resticprofile;
|
|
yamlFormat = pkgs.formats.yaml { };
|
|
baseProfile = import ./profiles/base.nix { inherit lib config; };
|
|
profiles = lib.recursiveUpdate baseProfile cfg.profiles;
|
|
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/`.
|
|
'';
|
|
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 = yamlFormat.generate "profiles" {
|
|
version = "2";
|
|
profiles = profiles;
|
|
};
|
|
};
|
|
}
|