populate file: add useChecksum

This commit is contained in:
tv 2018-11-28 08:34:19 +01:00
parent d92cc88a3c
commit 6f49342b2d
3 changed files with 13 additions and 3 deletions

View File

@ -16,6 +16,7 @@ let {
}; };
}; };
sanitize = x: lib.getAttr (lib.typeOf x) { sanitize = x: lib.getAttr (lib.typeOf x) {
bool = x;
list = map sanitize x; list = map sanitize x;
set = lib.mapAttrs set = lib.mapAttrs
(lib.const sanitize) (lib.const sanitize)

View File

@ -52,6 +52,10 @@
path = lib.mkOption { path = lib.mkOption {
type = lib.types.absolute-pathname; type = lib.types.absolute-pathname;
}; };
useChecksum = lib.mkOption {
default = false;
type = lib.types.bool;
};
}; };
}; };
git = lib.types.submodule { git = lib.types.submodule {

View File

@ -20,7 +20,11 @@ let
fi 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 */ '' pop.git = target: source: shell' target /* sh */ ''
if ! test -e ${quote target.path}; then if ! test -e ${quote target.path}; then
@ -78,7 +82,7 @@ let
${coreutils}/bin/touch -d "$pass_date" "$tmp_path" ${coreutils}/bin/touch -d "$pass_date" "$tmp_path"
done done
${rsync' target /* sh */ "$tmp_dir"} ${rsync' target {} /* sh */ "$tmp_dir"}
''; '';
pop.pipe = target: source: /* sh */ '' pop.pipe = target: source: /* sh */ ''
@ -100,12 +104,13 @@ let
${pop.${source.type} target' source'} ${pop.${source.type} target' source'}
''; '';
rsync' = target: sourcePath: /* sh */ '' rsync' = target: config: sourcePath: /* sh */ ''
source_path=${sourcePath} source_path=${sourcePath}
if test -d "$source_path"; then if test -d "$source_path"; then
source_path=$source_path/ source_path=$source_path/
fi fi
${rsync}/bin/rsync \ ${rsync}/bin/rsync \
${optionalString (config.useChecksum or false) /* sh */ "--checksum"} \
-e ${quote (ssh' target)} \ -e ${quote (ssh' target)} \
-vFrlptD \ -vFrlptD \
--delete-excluded \ --delete-excluded \