diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-09-13 22:26:16 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-09-13 23:32:14 +0200 |
commit | 7d4eb3f1b7c74b3812c1873b6136a18387310bb8 (patch) | |
tree | 972ba50954d3dfc893d31b0fa8c6a2c6bcf31351 /lib | |
parent | 19b39dcc934aba37e39b5f492c2919dd93b74870 (diff) | |
download | nixpkgs-7d4eb3f1b7c74b3812c1873b6136a18387310bb8.tar nixpkgs-7d4eb3f1b7c74b3812c1873b6136a18387310bb8.tar.gz nixpkgs-7d4eb3f1b7c74b3812c1873b6136a18387310bb8.tar.bz2 nixpkgs-7d4eb3f1b7c74b3812c1873b6136a18387310bb8.tar.lz nixpkgs-7d4eb3f1b7c74b3812c1873b6136a18387310bb8.tar.xz nixpkgs-7d4eb3f1b7c74b3812c1873b6136a18387310bb8.tar.zst nixpkgs-7d4eb3f1b7c74b3812c1873b6136a18387310bb8.zip |
lib.fileset.toSource: Evaluate fileset even for empty directories
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fileset/default.nix | 4 | ||||
-rw-r--r-- | lib/fileset/internal.nix | 1 | ||||
-rwxr-xr-x | lib/fileset/tests.sh | 3 |
3 files changed, 7 insertions, 1 deletions
diff --git a/lib/fileset/default.nix b/lib/fileset/default.nix index b3012526552..51002332a31 100644 --- a/lib/fileset/default.nix +++ b/lib/fileset/default.nix @@ -92,6 +92,7 @@ The only way to change which files get added to the store is by changing the `fi fileset = _coerce "lib.fileset.toSource: `fileset`" filesetPath; rootFilesystemRoot = (splitRoot root).root; filesetFilesystemRoot = (splitRoot fileset._internalBase).root; + filter = _toSourceFilter fileset; in if ! isPath root then if isStringLike root then @@ -123,9 +124,10 @@ The only way to change which files get added to the store is by changing the `fi - Set `root` to ${toString fileset._internalBase} or any directory higher up. This changes the layout of the resulting store path. - Set `fileset` to a file set that cannot contain files outside the `root` ${toString root}. This could change the files included in the result.'' else + builtins.seq filter cleanSourceWith { name = "source"; src = root; - filter = _toSourceFilter fileset; + inherit filter; }; } diff --git a/lib/fileset/internal.nix b/lib/fileset/internal.nix index ae8eb20e3ed..946ea1014f3 100644 --- a/lib/fileset/internal.nix +++ b/lib/fileset/internal.nix @@ -294,6 +294,7 @@ rec { in # Special case because the code below assumes that the _internalBase is always included in the result # which shouldn't be done when we have no files at all in the base + # This also forces the tree before returning the filter, leads to earlier error messages if tree == null then empty else diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh index e27610573a8..5bd798ae794 100755 --- a/lib/fileset/tests.sh +++ b/lib/fileset/tests.sh @@ -246,6 +246,9 @@ expectFailure 'toSource { root = ./a; fileset = ./a; }' 'lib.fileset.toSource: ` \s*- If you want to import the file into the store _with_ a containing directory, set `root` to the containing directory, such as '"$work"', and set `fileset` to the file path.' rm -rf * +# The fileset argument should be evaluated, even if the directory is empty +expectFailure 'toSource { root = ./.; fileset = abort "This should be evaluated"; }' 'evaluation aborted with the following error message: '\''This should be evaluated'\' + # Only paths under `root` should be able to influence the result mkdir a expectFailure 'toSource { root = ./a; fileset = ./.; }' 'lib.fileset.toSource: `fileset` could contain files in '"$work"', which is not under the `root` '"$work"'/a. Potential solutions: |