mirror of
https://cgit.krebsco.de/krops
synced 2024-11-26 21:19:47 +01:00
support for include filters
- Added a new option for `file` sources, which allows to specify a list of `include` and `exclude` filters - Added a new option for `file` sources, which allows to disable the `--delete-excluded` behaviour.
This commit is contained in:
parent
f1b7112ac3
commit
56d4dc28b3
3 changed files with 50 additions and 2 deletions
11
README.md
11
README.md
|
@ -157,6 +157,17 @@ Supported attributes:
|
||||||
manual](https://download.samba.org/pub/rsync/rsync.html) for further
|
manual](https://download.samba.org/pub/rsync/rsync.html) for further
|
||||||
information.
|
information.
|
||||||
|
|
||||||
|
* `filters` (optional)
|
||||||
|
List of filters that should be passed to rsync. Filters are specified as
|
||||||
|
attribute sets with the attributes `type` and `pattern`. Supported filter
|
||||||
|
types are `include` and `exclude`. This allows for more advanced
|
||||||
|
configurations.
|
||||||
|
|
||||||
|
* `deleteExcluded` (optional)
|
||||||
|
boolean that controls whether the excluded directories should be deleted
|
||||||
|
if they exist on the target. This is passed to the `--delete-excluded` option
|
||||||
|
of rsync. Defaults to `true`.
|
||||||
|
|
||||||
|
|
||||||
### `git`
|
### `git`
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,18 @@
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
filter = lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
type = lib.mkOption {
|
||||||
|
type = lib.types.enum ["include" "exclude"];
|
||||||
|
default = "exclude";
|
||||||
|
};
|
||||||
|
pattern = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
source-types = {
|
source-types = {
|
||||||
derivation = lib.types.submodule {
|
derivation = lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
|
@ -76,6 +88,28 @@
|
||||||
default = [];
|
default = [];
|
||||||
example = [".git"];
|
example = [".git"];
|
||||||
};
|
};
|
||||||
|
filters = lib.mkOption {
|
||||||
|
type = lib.types.listOf filter;
|
||||||
|
default = [];
|
||||||
|
example = [
|
||||||
|
{
|
||||||
|
type = "include";
|
||||||
|
pattern = "*.nix";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "include";
|
||||||
|
pattern = "*/";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "exclude";
|
||||||
|
pattern = "*";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
deleteExcluded = lib.mkOption {
|
||||||
|
default = true;
|
||||||
|
type = lib.types.bool;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
git = lib.types.submodule {
|
git = lib.types.submodule {
|
||||||
|
|
|
@ -45,7 +45,7 @@ let
|
||||||
'';
|
'';
|
||||||
|
|
||||||
pop.file = target: source: let
|
pop.file = target: source: let
|
||||||
configAttrs = ["useChecksum" "exclude"];
|
configAttrs = ["useChecksum" "exclude" "filters" "deleteExcluded"];
|
||||||
config = filterAttrs (name: _: elem name configAttrs) source;
|
config = filterAttrs (name: _: elem name configAttrs) source;
|
||||||
in
|
in
|
||||||
rsync' target config (quote source.path);
|
rsync' target config (quote source.path);
|
||||||
|
@ -161,9 +161,12 @@ let
|
||||||
${concatMapStringsSep " "
|
${concatMapStringsSep " "
|
||||||
(pattern: /* sh */ "--exclude ${quote pattern}")
|
(pattern: /* sh */ "--exclude ${quote pattern}")
|
||||||
(config.exclude or [])} \
|
(config.exclude or [])} \
|
||||||
|
${concatMapStringsSep " "
|
||||||
|
(filter: /* sh */ "--${filter.type} ${quote filter.pattern}")
|
||||||
|
(config.filters or [])} \
|
||||||
-e ${quote (ssh' target)} \
|
-e ${quote (ssh' target)} \
|
||||||
-vFrlptD \
|
-vFrlptD \
|
||||||
--delete-excluded \
|
${optionalString (config.deleteExcluded or true) /* sh */ "--delete-excluded"} \
|
||||||
"$source_path" \
|
"$source_path" \
|
||||||
${quote (
|
${quote (
|
||||||
optionalString (!isLocalTarget target) (
|
optionalString (!isLocalTarget target) (
|
||||||
|
|
Loading…
Reference in a new issue