diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-09-21 00:59:09 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-03 21:27:42 +0200 |
commit | 86802e19ceffbdff6a2a80dbec2d5f14f9f40efa (patch) | |
tree | 7120f9c57be7f996226ff80be4faa1d838251d76 /lib/fileset | |
parent | b3c2281219893ee422e18f9d3917e8cc8216114d (diff) | |
download | nixpkgs-86802e19ceffbdff6a2a80dbec2d5f14f9f40efa.tar nixpkgs-86802e19ceffbdff6a2a80dbec2d5f14f9f40efa.tar.gz nixpkgs-86802e19ceffbdff6a2a80dbec2d5f14f9f40efa.tar.bz2 nixpkgs-86802e19ceffbdff6a2a80dbec2d5f14f9f40efa.tar.lz nixpkgs-86802e19ceffbdff6a2a80dbec2d5f14f9f40efa.tar.xz nixpkgs-86802e19ceffbdff6a2a80dbec2d5f14f9f40efa.tar.zst nixpkgs-86802e19ceffbdff6a2a80dbec2d5f14f9f40efa.zip |
lib.fileset: _simplifyTree -> _normaliseTreeFilter
Diffstat (limited to 'lib/fileset')
-rw-r--r-- | lib/fileset/internal.nix | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/fileset/internal.nix b/lib/fileset/internal.nix index 43e6dd31b71..ad10b9ac0bb 100644 --- a/lib/fileset/internal.nix +++ b/lib/fileset/internal.nix @@ -241,22 +241,22 @@ rec { // value; /* - Simplify a filesetTree recursively: - - Replace all directories that have no files with `null` + A normalisation of a filesetTree suitable for use in builtins.path-based filtering: + - Replace all directories that have no files with `null`. This removes directories that would be empty - - Replace all directories with all files with `"directory"` + - Replace all directories with all files with `"directory"`. This speeds up the source filter function Note that this function is strict, it evaluates the entire tree Type: Path -> filesetTree -> filesetTree */ - _simplifyTree = path: tree: + _normaliseTreeFilter = path: tree: if tree == "directory" || isAttrs tree then let entries = _directoryEntries path tree; - simpleSubtrees = mapAttrs (name: _simplifyTree (path + "/${name}")) entries; - subtreeValues = attrValues simpleSubtrees; + normalisedSubtrees = mapAttrs (name: _normaliseTreeFilter (path + "/${name}")) entries; + subtreeValues = attrValues normalisedSubtrees; in # This triggers either when all files in a directory are filtered out # Or when the directory doesn't contain any files at all @@ -266,7 +266,7 @@ rec { else if all isString subtreeValues then "directory" else - simpleSubtrees + normalisedSubtrees else tree; @@ -277,7 +277,7 @@ rec { let # Simplify the tree, necessary to make sure all empty directories are null # which has the effect that they aren't included in the result - tree = _simplifyTree fileset._internalBase fileset._internalTree; + tree = _normaliseTreeFilter fileset._internalBase fileset._internalTree; # The base path as a string with a single trailing slash baseString = |