diff options
| author | Jörg Thalheim <joerg@thalheim.io> | 2019-12-22 13:07:51 +0000 | 
|---|---|---|
| committer | Lassulus <github@lassul.us> | 2019-12-23 21:18:35 +0100 | 
| commit | fff9b24ec98515cdd19cb3d6490b6214bacae792 (patch) | |
| tree | 93f9ffe1d0e3dc8fddc5cf6546ae490ba4a79102 | |
| parent | f2f8cbf1afcb2c26d11e5f82c0b523b2cb10205c (diff) | |
populate file: add exclude option
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | lib/types/populate.nix | 5 | ||||
| -rw-r--r-- | pkgs/populate/default.nix | 7 | 
3 files changed, 17 insertions, 2 deletions
| @@ -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 \ | 
