summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2015-04-13 17:10:04 -0500
committerAustin Seipp <aseipp@pobox.com>2015-04-13 17:10:04 -0500
commit409da39c08d6d192ccc04f2069fa2e3447f54a35 (patch)
tree78ed67b6a445e66158b1f49e55c2e44c7f620764 /nixos
parentd48ff3a9b42735830b9f9f9d759538804ba25db7 (diff)
parent66bfc3bbe6b941096c819caa1d4d3cc6170d2df4 (diff)
downloadnixpkgs-409da39c08d6d192ccc04f2069fa2e3447f54a35.tar
nixpkgs-409da39c08d6d192ccc04f2069fa2e3447f54a35.tar.gz
nixpkgs-409da39c08d6d192ccc04f2069fa2e3447f54a35.tar.bz2
nixpkgs-409da39c08d6d192ccc04f2069fa2e3447f54a35.tar.lz
nixpkgs-409da39c08d6d192ccc04f2069fa2e3447f54a35.tar.xz
nixpkgs-409da39c08d6d192ccc04f2069fa2e3447f54a35.tar.zst
nixpkgs-409da39c08d6d192ccc04f2069fa2e3447f54a35.zip
Merge pull request #7163 from joachifm/tarsnap-bandwidth-options
tarsnap module: add options for controlling bandwidth
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/backup/tarsnap.nix34
1 files changed, 31 insertions, 3 deletions
diff --git a/nixos/modules/services/backup/tarsnap.nix b/nixos/modules/services/backup/tarsnap.nix
index 155161945cd..f8eeb437844 100644
--- a/nixos/modules/services/backup/tarsnap.nix
+++ b/nixos/modules/services/backup/tarsnap.nix
@@ -5,20 +5,21 @@ with lib;
 let
   cfg = config.services.tarsnap;
 
-  optionalNullStr = e: v: if e == null then "" else v;
-
   configFile = cfg: ''
     cachedir ${config.services.tarsnap.cachedir}
     keyfile  ${config.services.tarsnap.keyfile}
     ${optionalString cfg.nodump "nodump"}
     ${optionalString cfg.printStats "print-stats"}
     ${optionalString cfg.printStats "humanize-numbers"}
-    ${optionalNullStr cfg.checkpointBytes "checkpoint-bytes "+cfg.checkpointBytes}
+    ${optionalString (cfg.checkpointBytes != null) ("checkpoint-bytes "+cfg.checkpointBytes)}
     ${optionalString cfg.aggressiveNetworking "aggressive-networking"}
     ${concatStringsSep "\n" (map (v: "exclude "+v) cfg.excludes)}
     ${concatStringsSep "\n" (map (v: "include "+v) cfg.includes)}
     ${optionalString cfg.lowmem "lowmem"}
     ${optionalString cfg.verylowmem "verylowmem"}
+    ${optionalString (cfg.maxbw != null) ("maxbw "+toString cfg.maxbw)}
+    ${optionalString (cfg.maxbwRateUp != null) ("maxbw-rate-up "+toString cfg.maxbwRateUp)}
+    ${optionalString (cfg.maxbwRateDown != null) ("maxbw-rate-down "+toString cfg.maxbwRateDown)}
   '';
 in
 {
@@ -166,6 +167,33 @@ in
                   slowing down the archiving process.
                 '';
               };
+
+              maxbw = mkOption {
+                type = types.nullOr types.int;
+                default = null;
+                description = ''
+                  Abort archival if upstream bandwidth usage in bytes
+                  exceeds this threshold.
+                '';
+              };
+
+              maxbwRateUp = mkOption {
+                type = types.nullOr types.int;
+                default = null;
+                example = literalExample "25 * 1000";
+                description = ''
+                  Upload bandwidth rate limit in bytes.
+                '';
+              };
+
+              maxbwRateDown = mkOption {
+                type = types.nullOr types.int;
+                default = null;
+                example = literalExample "50 * 1000";
+                description = ''
+                  Download bandwidth rate limit in bytes.
+                '';
+              };
             };
           }
         ));