diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2024-01-11 10:06:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-11 10:06:20 -0500 |
commit | 60eb80593f3a18aebc7672ad7007cb23c14db061 (patch) | |
tree | f17f8492bed32f78c04d9d4e9ffd2b672af85943 | |
parent | 4dd5171652018e29bf9e496522df3be51d615a2c (diff) | |
parent | ba48ab4b954dd1c8af388d1c5a33bbd62373c6f5 (diff) |
Merge pull request #9738 from shlevy/ifd-buildStore-2.18
(Backport #9661) Build IFD in the build store when using eval-store.
-rw-r--r-- | src/libexpr/primops.cc | 24 | ||||
-rw-r--r-- | tests/functional/eval-store.sh | 8 | ||||
-rw-r--r-- | tests/functional/ifd.nix | 10 | ||||
-rw-r--r-- | tests/functional/remote-store.sh | 13 |
4 files changed, 35 insertions, 20 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index d8d3e8bee..c2f6609f4 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -82,16 +82,15 @@ StringMap EvalState::realiseContext(const NixStringContext & context) /* Build/substitute the context. */ std::vector<DerivedPath> buildReqs; for (auto & d : drvs) buildReqs.emplace_back(DerivedPath { d }); - store->buildPaths(buildReqs); + buildStore->buildPaths(buildReqs, bmNormal, store); + + StorePathSet outputsToCopyAndAllow; for (auto & drv : drvs) { - auto outputs = resolveDerivedPath(*store, drv); + auto outputs = resolveDerivedPath(*buildStore, drv, &*store); for (auto & [outputName, outputPath] : outputs) { - /* Add the output of this derivations to the allowed - paths. */ - if (allowedPaths) { - allowPath(outputPath); - } + outputsToCopyAndAllow.insert(outputPath); + /* Get all the output paths corresponding to the placeholders we had */ if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) { res.insert_or_assign( @@ -100,12 +99,21 @@ StringMap EvalState::realiseContext(const NixStringContext & context) .drvPath = drv.drvPath, .output = outputName, }).render(), - store->printStorePath(outputPath) + buildStore->printStorePath(outputPath) ); } } } + if (store != buildStore) copyClosure(*buildStore, *store, outputsToCopyAndAllow); + if (allowedPaths) { + for (auto & outputPath : outputsToCopyAndAllow) { + /* Add the output of this derivations to the allowed + paths. */ + allowPath(store->toRealPath(outputPath)); + } + } + return res; } diff --git a/tests/functional/eval-store.sh b/tests/functional/eval-store.sh index 8fc859730..a34f3e82f 100644 --- a/tests/functional/eval-store.sh +++ b/tests/functional/eval-store.sh @@ -28,3 +28,11 @@ nix-build dependencies.nix --eval-store "$eval_store" -o "$TEST_ROOT/result" [[ -e $TEST_ROOT/result/foobar ]] (! ls $NIX_STORE_DIR/*.drv) ls $eval_store/nix/store/*.drv + +clearStore +rm -rf "$eval_store" + +# Confirm that import-from-derivation builds on the build store +[[ $(nix eval --eval-store "$eval_store?require-sigs=false" --impure --raw --file ./ifd.nix) = hi ]] +ls $NIX_STORE_DIR/*dependencies-top/foobar +(! ls $eval_store/nix/store/*dependencies-top/foobar) diff --git a/tests/functional/ifd.nix b/tests/functional/ifd.nix new file mode 100644 index 000000000..d0b9b54ad --- /dev/null +++ b/tests/functional/ifd.nix @@ -0,0 +1,10 @@ +with import ./config.nix; +import ( + mkDerivation { + name = "foo"; + bla = import ./dependencies.nix {}; + buildCommand = " + echo \\\"hi\\\" > $out + "; + } +) diff --git a/tests/functional/remote-store.sh b/tests/functional/remote-store.sh index 50e6f24b9..7649964ef 100644 --- a/tests/functional/remote-store.sh +++ b/tests/functional/remote-store.sh @@ -19,18 +19,7 @@ else fi # Test import-from-derivation through the daemon. -[[ $(nix eval --impure --raw --expr ' - with import ./config.nix; - import ( - mkDerivation { - name = "foo"; - bla = import ./dependencies.nix {}; - buildCommand = " - echo \\\"hi\\\" > $out - "; - } - ) -') = hi ]] +[[ $(nix eval --impure --raw --file ./ifd.nix) = hi ]] storeCleared=1 NIX_REMOTE_=$NIX_REMOTE $SHELL ./user-envs.sh |