forked from lix-project/lix
Merge pull request #9738 from shlevy/ifd-buildStore-2.18
(Backport #9661) Build IFD in the build store when using eval-store.
This commit is contained in:
commit
60eb80593f
|
@ -82,16 +82,15 @@ StringMap EvalState::realiseContext(const NixStringContext & context)
|
||||||
/* Build/substitute the context. */
|
/* Build/substitute the context. */
|
||||||
std::vector<DerivedPath> buildReqs;
|
std::vector<DerivedPath> buildReqs;
|
||||||
for (auto & d : drvs) buildReqs.emplace_back(DerivedPath { d });
|
for (auto & d : drvs) buildReqs.emplace_back(DerivedPath { d });
|
||||||
store->buildPaths(buildReqs);
|
buildStore->buildPaths(buildReqs, bmNormal, store);
|
||||||
|
|
||||||
|
StorePathSet outputsToCopyAndAllow;
|
||||||
|
|
||||||
for (auto & drv : drvs) {
|
for (auto & drv : drvs) {
|
||||||
auto outputs = resolveDerivedPath(*store, drv);
|
auto outputs = resolveDerivedPath(*buildStore, drv, &*store);
|
||||||
for (auto & [outputName, outputPath] : outputs) {
|
for (auto & [outputName, outputPath] : outputs) {
|
||||||
/* Add the output of this derivations to the allowed
|
outputsToCopyAndAllow.insert(outputPath);
|
||||||
paths. */
|
|
||||||
if (allowedPaths) {
|
|
||||||
allowPath(outputPath);
|
|
||||||
}
|
|
||||||
/* Get all the output paths corresponding to the placeholders we had */
|
/* Get all the output paths corresponding to the placeholders we had */
|
||||||
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
||||||
res.insert_or_assign(
|
res.insert_or_assign(
|
||||||
|
@ -100,12 +99,21 @@ StringMap EvalState::realiseContext(const NixStringContext & context)
|
||||||
.drvPath = drv.drvPath,
|
.drvPath = drv.drvPath,
|
||||||
.output = outputName,
|
.output = outputName,
|
||||||
}).render(),
|
}).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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,3 +28,11 @@ nix-build dependencies.nix --eval-store "$eval_store" -o "$TEST_ROOT/result"
|
||||||
[[ -e $TEST_ROOT/result/foobar ]]
|
[[ -e $TEST_ROOT/result/foobar ]]
|
||||||
(! ls $NIX_STORE_DIR/*.drv)
|
(! ls $NIX_STORE_DIR/*.drv)
|
||||||
ls $eval_store/nix/store/*.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)
|
||||||
|
|
10
tests/functional/ifd.nix
Normal file
10
tests/functional/ifd.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
with import ./config.nix;
|
||||||
|
import (
|
||||||
|
mkDerivation {
|
||||||
|
name = "foo";
|
||||||
|
bla = import ./dependencies.nix {};
|
||||||
|
buildCommand = "
|
||||||
|
echo \\\"hi\\\" > $out
|
||||||
|
";
|
||||||
|
}
|
||||||
|
)
|
|
@ -19,18 +19,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test import-from-derivation through the daemon.
|
# Test import-from-derivation through the daemon.
|
||||||
[[ $(nix eval --impure --raw --expr '
|
[[ $(nix eval --impure --raw --file ./ifd.nix) = hi ]]
|
||||||
with import ./config.nix;
|
|
||||||
import (
|
|
||||||
mkDerivation {
|
|
||||||
name = "foo";
|
|
||||||
bla = import ./dependencies.nix {};
|
|
||||||
buildCommand = "
|
|
||||||
echo \\\"hi\\\" > $out
|
|
||||||
";
|
|
||||||
}
|
|
||||||
)
|
|
||||||
') = hi ]]
|
|
||||||
|
|
||||||
storeCleared=1 NIX_REMOTE_=$NIX_REMOTE $SHELL ./user-envs.sh
|
storeCleared=1 NIX_REMOTE_=$NIX_REMOTE $SHELL ./user-envs.sh
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue