aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2018-11-28 08:34:19 +0100
committertv <tv@krebsco.de>2018-11-28 12:45:21 +0100
commit6f49342b2d5973478f1f5eb6f8d6307059e7bcf7 (patch)
tree1407762405a66c4f5a0d363a98d7874f769bccad
parentd92cc88a3ccfb378d045b35032ee3c0a4f5f860f (diff)
populate file: add useChecksumv1.8.0
-rw-r--r--lib/default.nix1
-rw-r--r--lib/types/populate.nix4
-rw-r--r--pkgs/populate/default.nix11
3 files changed, 13 insertions, 3 deletions
diff --git a/lib/default.nix b/lib/default.nix
index cf57316..48e005e 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -16,6 +16,7 @@ let {
};
};
sanitize = x: lib.getAttr (lib.typeOf x) {
+ bool = x;
list = map sanitize x;
set = lib.mapAttrs
(lib.const sanitize)
diff --git a/lib/types/populate.nix b/lib/types/populate.nix
index f35786d..2cd3267 100644
--- a/lib/types/populate.nix
+++ b/lib/types/populate.nix
@@ -52,6 +52,10 @@
path = lib.mkOption {
type = lib.types.absolute-pathname;
};
+ useChecksum = lib.mkOption {
+ default = false;
+ type = lib.types.bool;
+ };
};
};
git = lib.types.submodule {
diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix
index d24cbec..fad6d18 100644
--- a/pkgs/populate/default.nix
+++ b/pkgs/populate/default.nix
@@ -20,7 +20,11 @@ let
fi
'';
- pop.file = target: source: rsync' target (quote source.path);
+ pop.file = target: source: let
+ configAttrs = ["useChecksum"];
+ config = filterAttrs (name: _: elem name configAttrs) source;
+ in
+ rsync' target config (quote source.path);
pop.git = target: source: shell' target /* sh */ ''
if ! test -e ${quote target.path}; then
@@ -78,7 +82,7 @@ let
${coreutils}/bin/touch -d "$pass_date" "$tmp_path"
done
- ${rsync' target /* sh */ "$tmp_dir"}
+ ${rsync' target {} /* sh */ "$tmp_dir"}
'';
pop.pipe = target: source: /* sh */ ''
@@ -100,12 +104,13 @@ let
${pop.${source.type} target' source'}
'';
- rsync' = target: sourcePath: /* sh */ ''
+ rsync' = target: config: sourcePath: /* sh */ ''
source_path=${sourcePath}
if test -d "$source_path"; then
source_path=$source_path/
fi
${rsync}/bin/rsync \
+ ${optionalString (config.useChecksum or false) /* sh */ "--checksum"} \
-e ${quote (ssh' target)} \
-vFrlptD \
--delete-excluded \