mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 13:11:00 +01:00
Simplify nix develop "gathering derivation environment"
Before, had some funny logic with an unnecessary is CA enabled branch, and erroneous use of the comma operator. Now, take advantage of the new `Derivation::fillInOutputPaths` to fill in input addresses (and output path env vars) in a much-more lightweight manner. Also, fix `nix develop` on fixed-output derivations so that weird things don't happen when we have that experimental feature enabled. As a slight behavior change, if the original derivation was content-addressing this one will be too, but I really don't think that matters --- if anything, it is a slight improvement for users that have already opted into content-addressing anyways.
This commit is contained in:
parent
e91b7d1732
commit
801cb16131
2 changed files with 20 additions and 24 deletions
|
|
@ -272,26 +272,24 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
|
|||
drv.name += "-env";
|
||||
drv.env.emplace("name", drv.name);
|
||||
drv.inputSrcs.insert(std::move(getEnvShPath));
|
||||
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
||||
for (auto & output : drv.outputs) {
|
||||
output.second = DerivationOutput::Deferred{}, drv.env[output.first] = hashPlaceholder(output.first);
|
||||
}
|
||||
} else {
|
||||
for (auto & output : drv.outputs) {
|
||||
output.second = DerivationOutput::Deferred{};
|
||||
drv.env[output.first] = "";
|
||||
}
|
||||
auto hashesModulo = hashDerivationModulo(*evalStore, drv, true);
|
||||
|
||||
for (auto & output : drv.outputs) {
|
||||
Hash h = hashesModulo.hashes.at(output.first);
|
||||
auto outPath = store->makeOutputPath(output.first, h, drv.name);
|
||||
output.second = DerivationOutput::InputAddressed{
|
||||
.path = outPath,
|
||||
};
|
||||
drv.env[output.first] = store->printStorePath(outPath);
|
||||
}
|
||||
for (auto & [outputName, output] : drv.outputs) {
|
||||
std::visit(
|
||||
overloaded{
|
||||
[&](const DerivationOutput::InputAddressed &) {
|
||||
output = DerivationOutput::Deferred{};
|
||||
drv.env[outputName] = "";
|
||||
},
|
||||
[&](const DerivationOutput::CAFixed &) {
|
||||
output = DerivationOutput::Deferred{};
|
||||
drv.env[outputName] = "";
|
||||
},
|
||||
[&](const auto &) {
|
||||
// Do nothing for other types (CAFloating, Deferred, Impure)
|
||||
},
|
||||
},
|
||||
output.raw);
|
||||
}
|
||||
drv.fillInOutputPaths(*evalStore);
|
||||
|
||||
auto shellDrvPath = writeDerivation(*evalStore, drv);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue