diff options
author | Guillaume Girol <symphorien+git@xlumurb.eu> | 2021-04-25 12:00:00 +0000 |
---|---|---|
committer | Symphorien Gibol <symphorien+git@xlumurb.eu> | 2021-04-25 20:34:38 +0200 |
commit | 166d5cc8514427125c62b6247670d7439656ced6 (patch) | |
tree | 78d50eba89d577d75056de81d63b2aabf7097503 /nixos/modules/services/backup/duplicity.nix | |
parent | e019872af81e4013fd518fcacfba74b1de21a50e (diff) | |
download | nixpkgs-166d5cc8514427125c62b6247670d7439656ced6.tar nixpkgs-166d5cc8514427125c62b6247670d7439656ced6.tar.gz nixpkgs-166d5cc8514427125c62b6247670d7439656ced6.tar.bz2 nixpkgs-166d5cc8514427125c62b6247670d7439656ced6.tar.lz nixpkgs-166d5cc8514427125c62b6247670d7439656ced6.tar.xz nixpkgs-166d5cc8514427125c62b6247670d7439656ced6.tar.zst nixpkgs-166d5cc8514427125c62b6247670d7439656ced6.zip |
nixos/duplicity: format
Diffstat (limited to 'nixos/modules/services/backup/duplicity.nix')
-rw-r--r-- | nixos/modules/services/backup/duplicity.nix | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/nixos/modules/services/backup/duplicity.nix b/nixos/modules/services/backup/duplicity.nix index a8d56424862..7bf81a938f1 100644 --- a/nixos/modules/services/backup/duplicity.nix +++ b/nixos/modules/services/backup/duplicity.nix @@ -1,16 +1,17 @@ -{ config, lib, pkgs, ...}: +{ config, lib, pkgs, ... }: with lib; - let cfg = config.services.duplicity; stateDirectory = "/var/lib/duplicity"; - localTarget = if hasPrefix "file://" cfg.targetUrl + localTarget = + if hasPrefix "file://" cfg.targetUrl then removePrefix "file://" cfg.targetUrl else null; -in { +in +{ options.services.duplicity = { enable = mkEnableOption "backups with duplicity"; @@ -24,7 +25,7 @@ in { include = mkOption { type = types.listOf types.str; - default = []; + default = [ ]; example = [ "/home" ]; description = '' List of paths to include into the backups. See the FILE SELECTION @@ -35,7 +36,7 @@ in { exclude = mkOption { type = types.listOf types.str; - default = []; + default = [ ]; description = '' List of paths to exclude from backups. See the FILE SELECTION section in <citerefentry><refentrytitle>duplicity</refentrytitle> @@ -82,7 +83,7 @@ in { extraFlags = mkOption { type = types.listOf types.str; - default = []; + default = [ ]; example = [ "--full-if-older-than" "1M" ]; description = '' Extra command-line flags passed to duplicity. See @@ -101,15 +102,17 @@ in { serviceConfig = { ExecStart = '' - ${pkgs.duplicity}/bin/duplicity ${escapeShellArgs ( - [ - cfg.root - cfg.targetUrl - "--archive-dir" stateDirectory - ] - ++ concatMap (p: [ "--include" p ]) cfg.include - ++ concatMap (p: [ "--exclude" p ]) cfg.exclude - ++ cfg.extraFlags)} + ${pkgs.duplicity}/bin/duplicity ${escapeShellArgs ( + [ + cfg.root + cfg.targetUrl + "--archive-dir" + stateDirectory + ] + ++ concatMap (p: [ "--include" p ]) cfg.include + ++ concatMap (p: [ "--exclude" p ]) cfg.exclude + ++ cfg.extraFlags + )} ''; PrivateTmp = true; ProtectSystem = "strict"; @@ -130,7 +133,7 @@ in { assertions = singleton { # Duplicity will fail if the last file selection option is an include. It # is not always possible to detect but this simple case can be caught. - assertion = cfg.include != [] -> cfg.exclude != [] || cfg.extraFlags != []; + assertion = cfg.include != [ ] -> cfg.exclude != [ ] || cfg.extraFlags != [ ]; message = '' Duplicity will fail if you only specify included paths ("Because the default is to include all files, the expression is redundant. Exiting |