nixos/services.borgmatic: remove with lib;
This commit is contained in:
parent
f600d6a3b1
commit
ef50268985
@ -1,20 +1,17 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.borgmatic;
|
||||
settingsFormat = pkgs.formats.yaml { };
|
||||
|
||||
repository = with types; submodule {
|
||||
repository = with lib.types; submodule {
|
||||
options = {
|
||||
path = mkOption {
|
||||
path = lib.mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
Path to the repository
|
||||
'';
|
||||
};
|
||||
label = mkOption {
|
||||
label = lib.mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
Label to the repository
|
||||
@ -22,10 +19,10 @@ let
|
||||
};
|
||||
};
|
||||
};
|
||||
cfgType = with types; submodule {
|
||||
cfgType = with lib.types; submodule {
|
||||
freeformType = settingsFormat.type;
|
||||
options = {
|
||||
source_directories = mkOption {
|
||||
source_directories = lib.mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = ''
|
||||
@ -34,7 +31,7 @@ let
|
||||
'';
|
||||
example = [ "/home" "/etc" "/var/log/syslog*" "/home/user/path with spaces" ];
|
||||
};
|
||||
repositories = mkOption {
|
||||
repositories = lib.mkOption {
|
||||
type = listOf repository;
|
||||
default = [];
|
||||
description = ''
|
||||
@ -59,33 +56,33 @@ let
|
||||
in
|
||||
{
|
||||
options.services.borgmatic = {
|
||||
enable = mkEnableOption "borgmatic";
|
||||
enable = lib.mkEnableOption "borgmatic";
|
||||
|
||||
settings = mkOption {
|
||||
settings = lib.mkOption {
|
||||
description = ''
|
||||
See https://torsion.org/borgmatic/docs/reference/configuration/
|
||||
'';
|
||||
default = null;
|
||||
type = types.nullOr cfgType;
|
||||
type = lib.types.nullOr cfgType;
|
||||
};
|
||||
|
||||
configurations = mkOption {
|
||||
configurations = lib.mkOption {
|
||||
description = ''
|
||||
Set of borgmatic configurations, see https://torsion.org/borgmatic/docs/reference/configuration/
|
||||
'';
|
||||
default = { };
|
||||
type = types.attrsOf cfgType;
|
||||
type = lib.types.attrsOf cfgType;
|
||||
};
|
||||
|
||||
enableConfigCheck = mkEnableOption "checking all configurations during build time" // { default = true; };
|
||||
enableConfigCheck = lib.mkEnableOption "checking all configurations during build time" // { default = true; };
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
configFiles =
|
||||
(optionalAttrs (cfg.settings != null) { "borgmatic/config.yaml".source = cfgfile; }) //
|
||||
mapAttrs'
|
||||
(name: value: nameValuePair
|
||||
(lib.optionalAttrs (cfg.settings != null) { "borgmatic/config.yaml".source = cfgfile; }) //
|
||||
lib.mapAttrs'
|
||||
(name: value: lib.nameValuePair
|
||||
"borgmatic.d/${name}.yaml"
|
||||
{ source = settingsFormat.generate "${name}.yaml" value; })
|
||||
cfg.configurations;
|
||||
@ -94,12 +91,12 @@ in
|
||||
touch $out
|
||||
'';
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
lib.mkIf cfg.enable {
|
||||
|
||||
warnings = []
|
||||
++ optional (cfg.settings != null && cfg.settings ? location)
|
||||
++ lib.optional (cfg.settings != null && cfg.settings ? location)
|
||||
"`services.borgmatic.settings.location` is deprecated, please move your options out of sections to the global scope"
|
||||
++ optional (catAttrs "location" (attrValues cfg.configurations) != [])
|
||||
++ lib.optional (lib.catAttrs "location" (lib.attrValues cfg.configurations) != [])
|
||||
"`services.borgmatic.configurations.<name>.location` is deprecated, please move your options out of sections to the global scope"
|
||||
;
|
||||
|
||||
@ -112,6 +109,6 @@ in
|
||||
# Workaround: https://github.com/NixOS/nixpkgs/issues/81138
|
||||
systemd.timers.borgmatic.wantedBy = [ "timers.target" ];
|
||||
|
||||
system.checks = mkIf cfg.enableConfigCheck (mapAttrsToList borgmaticCheck configFiles);
|
||||
system.checks = lib.mkIf cfg.enableConfigCheck (lib.mapAttrsToList borgmaticCheck configFiles);
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user