mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
nixos/duplicity: format
This commit is contained in:
parent
e019872af8
commit
166d5cc851
1 changed files with 20 additions and 17 deletions
|
@ -1,16 +1,17 @@
|
||||||
{ config, lib, pkgs, ...}:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.duplicity;
|
cfg = config.services.duplicity;
|
||||||
|
|
||||||
stateDirectory = "/var/lib/duplicity";
|
stateDirectory = "/var/lib/duplicity";
|
||||||
|
|
||||||
localTarget = if hasPrefix "file://" cfg.targetUrl
|
localTarget =
|
||||||
|
if hasPrefix "file://" cfg.targetUrl
|
||||||
then removePrefix "file://" cfg.targetUrl else null;
|
then removePrefix "file://" cfg.targetUrl else null;
|
||||||
|
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options.services.duplicity = {
|
options.services.duplicity = {
|
||||||
enable = mkEnableOption "backups with duplicity";
|
enable = mkEnableOption "backups with duplicity";
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ in {
|
||||||
|
|
||||||
include = mkOption {
|
include = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [];
|
default = [ ];
|
||||||
example = [ "/home" ];
|
example = [ "/home" ];
|
||||||
description = ''
|
description = ''
|
||||||
List of paths to include into the backups. See the FILE SELECTION
|
List of paths to include into the backups. See the FILE SELECTION
|
||||||
|
@ -35,7 +36,7 @@ in {
|
||||||
|
|
||||||
exclude = mkOption {
|
exclude = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [];
|
default = [ ];
|
||||||
description = ''
|
description = ''
|
||||||
List of paths to exclude from backups. See the FILE SELECTION section in
|
List of paths to exclude from backups. See the FILE SELECTION section in
|
||||||
<citerefentry><refentrytitle>duplicity</refentrytitle>
|
<citerefentry><refentrytitle>duplicity</refentrytitle>
|
||||||
|
@ -82,7 +83,7 @@ in {
|
||||||
|
|
||||||
extraFlags = mkOption {
|
extraFlags = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [];
|
default = [ ];
|
||||||
example = [ "--full-if-older-than" "1M" ];
|
example = [ "--full-if-older-than" "1M" ];
|
||||||
description = ''
|
description = ''
|
||||||
Extra command-line flags passed to duplicity. See
|
Extra command-line flags passed to duplicity. See
|
||||||
|
@ -101,15 +102,17 @@ in {
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.duplicity}/bin/duplicity ${escapeShellArgs (
|
${pkgs.duplicity}/bin/duplicity ${escapeShellArgs (
|
||||||
[
|
[
|
||||||
cfg.root
|
cfg.root
|
||||||
cfg.targetUrl
|
cfg.targetUrl
|
||||||
"--archive-dir" stateDirectory
|
"--archive-dir"
|
||||||
]
|
stateDirectory
|
||||||
++ concatMap (p: [ "--include" p ]) cfg.include
|
]
|
||||||
++ concatMap (p: [ "--exclude" p ]) cfg.exclude
|
++ concatMap (p: [ "--include" p ]) cfg.include
|
||||||
++ cfg.extraFlags)}
|
++ concatMap (p: [ "--exclude" p ]) cfg.exclude
|
||||||
|
++ cfg.extraFlags
|
||||||
|
)}
|
||||||
'';
|
'';
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
ProtectSystem = "strict";
|
ProtectSystem = "strict";
|
||||||
|
@ -130,7 +133,7 @@ in {
|
||||||
assertions = singleton {
|
assertions = singleton {
|
||||||
# Duplicity will fail if the last file selection option is an include. It
|
# 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.
|
# 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 = ''
|
message = ''
|
||||||
Duplicity will fail if you only specify included paths ("Because the
|
Duplicity will fail if you only specify included paths ("Because the
|
||||||
default is to include all files, the expression is redundant. Exiting
|
default is to include all files, the expression is redundant. Exiting
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue