mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-02 11:53:27 +00:00
6afb255d97
these changes were generated with nixq 0.0.2, by running nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix two mentions of the mdDoc function remain in nixos/, both of which are inside of comments. Since lib.mdDoc is already defined as just id, this commit is a no-op as far as Nix (and the built manual) is concerned.
105 lines
3.3 KiB
Nix
105 lines
3.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.borgmatic;
|
|
settingsFormat = pkgs.formats.yaml { };
|
|
|
|
repository = with types; submodule {
|
|
options = {
|
|
path = mkOption {
|
|
type = str;
|
|
description = ''
|
|
Path to the repository
|
|
'';
|
|
};
|
|
label = mkOption {
|
|
type = str;
|
|
description = ''
|
|
Label to the repository
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
cfgType = with types; submodule {
|
|
freeformType = settingsFormat.type;
|
|
options = {
|
|
source_directories = mkOption {
|
|
type = nullOr (listOf str);
|
|
default = null;
|
|
description = ''
|
|
List of source directories and files to backup. Globs and tildes are
|
|
expanded. Do not backslash spaces in path names.
|
|
'';
|
|
example = [ "/home" "/etc" "/var/log/syslog*" "/home/user/path with spaces" ];
|
|
};
|
|
repositories = mkOption {
|
|
type = nullOr (listOf repository);
|
|
default = null;
|
|
description = ''
|
|
A required list of local or remote repositories with paths and
|
|
optional labels (which can be used with the --repository flag to
|
|
select a repository). Tildes are expanded. Multiple repositories are
|
|
backed up to in sequence. Borg placeholders can be used. See the
|
|
output of "borg help placeholders" for details. See ssh_command for
|
|
SSH options like identity file or port. If systemd service is used,
|
|
then add local repository paths in the systemd service file to the
|
|
ReadWritePaths list.
|
|
'';
|
|
example = [
|
|
{ path="ssh://user@backupserver/./sourcehostname.borg"; label="backupserver"; }
|
|
{ path="/mnt/backup"; label="local"; }
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
cfgfile = settingsFormat.generate "config.yaml" cfg.settings;
|
|
in
|
|
{
|
|
options.services.borgmatic = {
|
|
enable = mkEnableOption "borgmatic";
|
|
|
|
settings = mkOption {
|
|
description = ''
|
|
See https://torsion.org/borgmatic/docs/reference/configuration/
|
|
'';
|
|
default = null;
|
|
type = types.nullOr cfgType;
|
|
};
|
|
|
|
configurations = mkOption {
|
|
description = ''
|
|
Set of borgmatic configurations, see https://torsion.org/borgmatic/docs/reference/configuration/
|
|
'';
|
|
default = { };
|
|
type = types.attrsOf cfgType;
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
warnings = []
|
|
++ 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) != [])
|
|
"`services.borgmatic.configurations.<name>.location` is deprecated, please move your options out of sections to the global scope"
|
|
;
|
|
|
|
environment.systemPackages = [ pkgs.borgmatic ];
|
|
|
|
environment.etc = (optionalAttrs (cfg.settings != null) { "borgmatic/config.yaml".source = cfgfile; }) //
|
|
mapAttrs'
|
|
(name: value: nameValuePair
|
|
"borgmatic.d/${name}.yaml"
|
|
{ source = settingsFormat.generate "${name}.yaml" value; })
|
|
cfg.configurations;
|
|
|
|
systemd.packages = [ pkgs.borgmatic ];
|
|
|
|
# Workaround: https://github.com/NixOS/nixpkgs/issues/81138
|
|
systemd.timers.borgmatic.wantedBy = [ "timers.target" ];
|
|
};
|
|
}
|