populate file: add exclude option

This commit is contained in:
Jörg Thalheim 2019-12-22 13:07:51 +00:00 committed by Lassulus
parent f2f8cbf1af
commit fff9b24ec9
3 changed files with 17 additions and 2 deletions

View File

@ -114,6 +114,13 @@ Supported attributes:
boolean that controls whether file contents should be checked to decide
whether a file has changed. This is useful when `path` points at files
with mangled timestamps, e.g. the Nix store.
* `exclude` (optional)
List of patterns that should excluded from being synced. The list will be
passed to the `--exclude` option of [`rsync`](https://rsync.samba.org/).
Checkout the filter rules section in the [rsync
manual](https://download.samba.org/pub/rsync/rsync.html) for further
information.
### `git`

View File

@ -71,6 +71,11 @@
default = false;
type = lib.types.bool;
};
exclude = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = [".git"];
};
};
};
git = lib.types.submodule {

View File

@ -45,7 +45,7 @@ let
'';
pop.file = target: source: let
configAttrs = ["useChecksum"];
configAttrs = ["useChecksum" "exclude"];
config = filterAttrs (name: _: elem name configAttrs) source;
in
rsync' target config (quote source.path);
@ -156,8 +156,11 @@ let
source_path=$source_path/
fi
${rsync}/bin/rsync \
${optionalString (config.useChecksum or false) /* sh */ "--checksum"} \
${optionalString config.useChecksum /* sh */ "--checksum"} \
${optionalString target.sudo /* sh */ "--rsync-path=\"sudo rsync\""} \
${concatMapStringsSep " "
(pattern: /* sh */ "--exclude ${quote pattern}")
config.exclude} \
-e ${quote (ssh' target)} \
-vFrlptD \
--delete-excluded \