mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 05:00:58 +01:00
Merge pull request #14641 from obsidiansystems/simplify-nix-develop
Simplify `nix develop` "gathering derivation environment"
This commit is contained in:
commit
423e732b22
3 changed files with 35 additions and 20 deletions
|
|
@ -272,26 +272,24 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
|
||||||
drv.name += "-env";
|
drv.name += "-env";
|
||||||
drv.env.emplace("name", drv.name);
|
drv.env.emplace("name", drv.name);
|
||||||
drv.inputSrcs.insert(std::move(getEnvShPath));
|
drv.inputSrcs.insert(std::move(getEnvShPath));
|
||||||
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
for (auto & [outputName, output] : drv.outputs) {
|
||||||
for (auto & output : drv.outputs) {
|
std::visit(
|
||||||
output.second = DerivationOutput::Deferred{}, drv.env[output.first] = hashPlaceholder(output.first);
|
overloaded{
|
||||||
}
|
[&](const DerivationOutput::InputAddressed &) {
|
||||||
} else {
|
output = DerivationOutput::Deferred{};
|
||||||
for (auto & output : drv.outputs) {
|
drv.env[outputName] = "";
|
||||||
output.second = DerivationOutput::Deferred{};
|
},
|
||||||
drv.env[output.first] = "";
|
[&](const DerivationOutput::CAFixed &) {
|
||||||
}
|
output = DerivationOutput::Deferred{};
|
||||||
auto hashesModulo = hashDerivationModulo(*evalStore, drv, true);
|
drv.env[outputName] = "";
|
||||||
|
},
|
||||||
for (auto & output : drv.outputs) {
|
[&](const auto &) {
|
||||||
Hash h = hashesModulo.hashes.at(output.first);
|
// Do nothing for other types (CAFloating, Deferred, Impure)
|
||||||
auto outPath = store->makeOutputPath(output.first, h, drv.name);
|
},
|
||||||
output.second = DerivationOutput::InputAddressed{
|
},
|
||||||
.path = outPath,
|
output.raw);
|
||||||
};
|
|
||||||
drv.env[output.first] = store->printStorePath(outPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
drv.fillInOutputPaths(*evalStore);
|
||||||
|
|
||||||
auto shellDrvPath = writeDerivation(*evalStore, drv);
|
auto shellDrvPath = writeDerivation(*evalStore, drv);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ cat >"$TEST_ROOT"/marco/polo/default.nix <<EOF
|
||||||
(import $TEST_ROOT/lookup-test/shell.nix {}).polo
|
(import $TEST_ROOT/lookup-test/shell.nix {}).polo
|
||||||
EOF
|
EOF
|
||||||
chmod a+x "$TEST_ROOT"/marco/polo/default.nix
|
chmod a+x "$TEST_ROOT"/marco/polo/default.nix
|
||||||
(cd "$TEST_ROOT"/marco && ./polo/default.nix | grepQuiet "Polo")
|
(cd "$TEST_ROOT"/marco && ./polo/default.nix < /dev/null | grepQuiet "Polo")
|
||||||
|
|
||||||
# https://github.com/NixOS/nix/issues/11892
|
# https://github.com/NixOS/nix/issues/11892
|
||||||
mkdir "$TEST_ROOT"/issue-11892
|
mkdir "$TEST_ROOT"/issue-11892
|
||||||
|
|
@ -279,3 +279,10 @@ assert (!(args ? inNixShell));
|
||||||
(import $shellDotNix { }).shellDrv
|
(import $shellDotNix { }).shellDrv
|
||||||
EOF
|
EOF
|
||||||
nix-shell "$TEST_ROOT"/shell-ellipsis.nix --run "true"
|
nix-shell "$TEST_ROOT"/shell-ellipsis.nix --run "true"
|
||||||
|
|
||||||
|
# FIXME unclear why this (newly made) test is failing in this case.
|
||||||
|
if ! isTestOnNixOS; then
|
||||||
|
# `nix develop` should also work with fixed-output derivations
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
nix develop -f "$shellDotNix" fixed -c bash -c '[[ -n $stdenv ]]'
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,16 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Shells should also work with fixed-output derivations
|
||||||
|
fixed = mkDerivation {
|
||||||
|
name = "fixed";
|
||||||
|
FOO = "was a fixed-output derivation";
|
||||||
|
outputHash = "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik";
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
outputs = [ "out" ];
|
||||||
|
};
|
||||||
|
|
||||||
# Used by nix-shell -p
|
# Used by nix-shell -p
|
||||||
runCommand =
|
runCommand =
|
||||||
name: args: buildCommand:
|
name: args: buildCommand:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue