mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
parent
56605b4688
commit
2cf591a134
2 changed files with 29 additions and 13 deletions
|
@ -144,11 +144,19 @@ StorePath getDerivationEnvironment(ref<Store> store, const StorePath & drvPath)
|
||||||
/* Rehash and write the derivation. FIXME: would be nice to use
|
/* Rehash and write the derivation. FIXME: would be nice to use
|
||||||
'buildDerivation', but that's privileged. */
|
'buildDerivation', but that's privileged. */
|
||||||
drv.name += "-env";
|
drv.name += "-env";
|
||||||
|
drv.inputSrcs.insert(std::move(getEnvShPath));
|
||||||
|
if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
|
||||||
|
for (auto & output : drv.outputs) {
|
||||||
|
output.second = {
|
||||||
|
.output = DerivationOutputDeferred{},
|
||||||
|
};
|
||||||
|
drv.env[output.first] = "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (auto & output : drv.outputs) {
|
for (auto & output : drv.outputs) {
|
||||||
output.second = { .output = DerivationOutputInputAddressed { .path = StorePath::dummy } };
|
output.second = { .output = DerivationOutputInputAddressed { .path = StorePath::dummy } };
|
||||||
drv.env[output.first] = "";
|
drv.env[output.first] = "";
|
||||||
}
|
}
|
||||||
drv.inputSrcs.insert(std::move(getEnvShPath));
|
|
||||||
Hash h = std::get<0>(hashDerivationModulo(*store, drv, true));
|
Hash h = std::get<0>(hashDerivationModulo(*store, drv, true));
|
||||||
|
|
||||||
for (auto & output : drv.outputs) {
|
for (auto & output : drv.outputs) {
|
||||||
|
@ -156,14 +164,14 @@ StorePath getDerivationEnvironment(ref<Store> store, const StorePath & drvPath)
|
||||||
output.second = { .output = DerivationOutputInputAddressed { .path = outPath } };
|
output.second = { .output = DerivationOutputInputAddressed { .path = outPath } };
|
||||||
drv.env[output.first] = store->printStorePath(outPath);
|
drv.env[output.first] = store->printStorePath(outPath);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto shellDrvPath = writeDerivation(*store, drv);
|
auto shellDrvPath = writeDerivation(*store, drv);
|
||||||
|
|
||||||
/* Build the derivation. */
|
/* Build the derivation. */
|
||||||
store->buildPaths({DerivedPath::Built{shellDrvPath}});
|
store->buildPaths({DerivedPath::Built{shellDrvPath}});
|
||||||
|
|
||||||
for (auto & [_0, outputAndOptPath] : drv.outputsAndOptPaths(*store)) {
|
for (auto & [_0, optPath] : store->queryPartialDerivationOutputMap(shellDrvPath)) {
|
||||||
auto & [_1, optPath] = outputAndOptPath;
|
|
||||||
assert(optPath);
|
assert(optPath);
|
||||||
auto & outPath = *optPath;
|
auto & outPath = *optPath;
|
||||||
assert(store->isValidPath(outPath));
|
assert(store->isValidPath(outPath));
|
||||||
|
|
|
@ -6,6 +6,14 @@ if [[ -n ${CONTENT_ADDRESSED:-} ]]; then
|
||||||
nix-shell () {
|
nix-shell () {
|
||||||
command nix-shell --arg contentAddressed true "$@"
|
command nix-shell --arg contentAddressed true "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nix_develop() {
|
||||||
|
nix develop --arg contentAddressed true "$@"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nix_develop() {
|
||||||
|
nix develop "$@"
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test nix-shell -A
|
# Test nix-shell -A
|
||||||
|
@ -79,13 +87,13 @@ output=$($TEST_ROOT/spaced\ \\\'\"shell.shebang.rb abc ruby)
|
||||||
[ "$output" = '-e load(ARGV.shift) -- '"$TEST_ROOT"'/spaced \'\''"shell.shebang.rb abc ruby' ]
|
[ "$output" = '-e load(ARGV.shift) -- '"$TEST_ROOT"'/spaced \'\''"shell.shebang.rb abc ruby' ]
|
||||||
|
|
||||||
# Test 'nix develop'.
|
# Test 'nix develop'.
|
||||||
nix develop -f shell.nix shellDrv -c bash -c '[[ -n $stdenv ]]'
|
nix_develop -f shell.nix shellDrv -c bash -c '[[ -n $stdenv ]]'
|
||||||
|
|
||||||
# Ensure `nix develop -c` preserves stdin
|
# Ensure `nix develop -c` preserves stdin
|
||||||
echo foo | nix develop -f shell.nix shellDrv -c cat | grep -q foo
|
echo foo | nix develop -f shell.nix shellDrv -c cat | grep -q foo
|
||||||
|
|
||||||
# Ensure `nix develop -c` actually executes the command if stdout isn't a terminal
|
# Ensure `nix develop -c` actually executes the command if stdout isn't a terminal
|
||||||
nix develop -f shell.nix shellDrv -c echo foo |& grep -q foo
|
nix_develop -f shell.nix shellDrv -c echo foo |& grep -q foo
|
||||||
|
|
||||||
# Test 'nix print-dev-env'.
|
# Test 'nix print-dev-env'.
|
||||||
source <(nix print-dev-env -f shell.nix shellDrv)
|
source <(nix print-dev-env -f shell.nix shellDrv)
|
||||||
|
|
Loading…
Reference in a new issue