From 7308fde0bc0ee9a902891385453ef6313cb91194 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 23 Oct 2025 19:18:57 +0200 Subject: [PATCH] Allow access to the result of fetchClosure --- src/libexpr/primops/fetchClosure.cc | 6 ++++++ tests/functional/dependencies.builder0.sh | 2 ++ tests/functional/fetchClosure.sh | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/src/libexpr/primops/fetchClosure.cc b/src/libexpr/primops/fetchClosure.cc index 63da53aa9..6e1389814 100644 --- a/src/libexpr/primops/fetchClosure.cc +++ b/src/libexpr/primops/fetchClosure.cc @@ -64,6 +64,8 @@ static void runFetchClosureWithRewrite( .pos = state.positions[pos]}); } + state.allowClosure(toPath); + state.mkStorePathString(toPath, v); } @@ -91,6 +93,8 @@ static void runFetchClosureWithContentAddressedPath( .pos = state.positions[pos]}); } + state.allowClosure(fromPath); + state.mkStorePathString(fromPath, v); } @@ -115,6 +119,8 @@ static void runFetchClosureWithInputAddressedPath( .pos = state.positions[pos]}); } + state.allowClosure(fromPath); + state.mkStorePathString(fromPath, v); } diff --git a/tests/functional/dependencies.builder0.sh b/tests/functional/dependencies.builder0.sh index 6fbe4a07a..f680cf7f2 100644 --- a/tests/functional/dependencies.builder0.sh +++ b/tests/functional/dependencies.builder0.sh @@ -17,4 +17,6 @@ ln -s "$out" "$out"/self echo program > "$out"/program chmod +x "$out"/program +echo '1 + 2' > "$out"/foo.nix + echo FOO diff --git a/tests/functional/fetchClosure.sh b/tests/functional/fetchClosure.sh index 9b79ab396..85a83d192 100755 --- a/tests/functional/fetchClosure.sh +++ b/tests/functional/fetchClosure.sh @@ -99,6 +99,14 @@ clearStore [ -e "$caPath" ] +# Test import-from-derivation on the result of fetchClosure. +[[ $(nix eval -v --expr " + import \"\${builtins.fetchClosure { + fromStore = \"file://$cacheDir\"; + fromPath = $caPath; + }}/foo.nix\" +") = 3 ]] + # Check that URL query parameters aren't allowed. clearStore narCache=$TEST_ROOT/nar-cache