From fff9b24ec98515cdd19cb3d6490b6214bacae792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 22 Dec 2019 13:07:51 +0000 Subject: populate file: add exclude option --- README.md | 7 +++++++ lib/types/populate.nix | 5 +++++ pkgs/populate/default.nix | 7 +++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1191a2f..323d08b 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/lib/types/populate.nix b/lib/types/populate.nix index bf90ace..e23ddb0 100644 --- a/lib/types/populate.nix +++ b/lib/types/populate.nix @@ -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 { diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix index 2b283a8..3e02aea 100644 --- a/pkgs/populate/default.nix +++ b/pkgs/populate/default.nix @@ -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 \ -- cgit v1.2.3