1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 22:01:15 +02:00

Make "nix-build -A <derivation>.<output>" do the right thing

For example, given a derivation with outputs "out", "man" and "bin":

  $ nix-build -A pkg

produces ./result pointing to the "out" output;

  $ nix-build -A pkg.man

produces ./result-man pointing to the "man" output;

  $ nix-build -A pkg.all

produces ./result, ./result-man and ./result-bin;

  $ nix-build -A pkg.all -A pkg2

produces ./result, ./result-man, ./result-bin and ./result-2.
This commit is contained in:
Eelco Dolstra 2012-11-26 15:39:10 +01:00
parent a3d6585c5a
commit 46a369ad95
10 changed files with 106 additions and 20 deletions

View file

@ -82,20 +82,23 @@ void queryMissing(StoreAPI & store, const PathSet & targets,
if (done.find(*i) != done.end()) continue;
done.insert(*i);
if (isDerivation(*i)) {
if (!store.isValidPath(*i)) {
DrvPathWithOutputs i2 = parseDrvPathWithOutputs(*i);
if (isDerivation(i2.first)) {
if (!store.isValidPath(i2.first)) {
// FIXME: we could try to substitute p.
unknown.insert(*i);
continue;
}
Derivation drv = derivationFromPath(store, *i);
Derivation drv = derivationFromPath(store, i2.first);
PathSet invalid;
// FIXME: only fetch the desired outputs
foreach (DerivationOutputs::iterator, j, drv.outputs)
if (!store.isValidPath(j->second.path)) invalid.insert(j->second.path);
if (invalid.empty()) continue;
todoDrv.insert(*i);
todoDrv.insert(i2.first);
if (settings.useSubstitutes) query.insert(invalid.begin(), invalid.end());
}