Skip to content

Commit

Permalink
Get rid of basicDerivation::findOutput
Browse files Browse the repository at this point in the history
It's a tiny function which is:

 - hardly worth abstrating over, and also only used once.

 - doesn't work once we get CA drvs

I rewrote the one callsite to be forwards compatable with CA
derivations, and also potentially more performant: instead of reading in
the derivation it can ust consult the SQLite DB in the common case.
  • Loading branch information
Ericson2314 committed Jul 23, 2020
1 parent 4bfba13 commit 2274f63
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
8 changes: 0 additions & 8 deletions src/libstore/derivations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@

namespace nix {

const StorePath & BasicDerivation::findOutput(const string & id) const
{
auto i = outputs.find(id);
if (i == outputs.end())
throw Error("derivation has no output '%s'", id);
return i->second.path;
}


bool BasicDerivation::isBuiltin() const
{
Expand Down
4 changes: 0 additions & 4 deletions src/libstore/derivations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ struct BasicDerivation
BasicDerivation() { }
virtual ~BasicDerivation() { };

/* Return the path corresponding to the output identifier `id' in
the given derivation. */
const StorePath & findOutput(const std::string & id) const;

bool isBuiltin() const;

/* Return true iff this is a fixed-output derivation. */
Expand Down
3 changes: 2 additions & 1 deletion src/nix-env/nix-env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ static void queryInstSources(EvalState & state,

if (path.isDerivation()) {
elem.setDrvPath(state.store->printStorePath(path));
elem.setOutPath(state.store->printStorePath(state.store->derivationFromPath(path).findOutput("out")));
auto outputs = state.store->queryDerivationOutputMap(path);
elem.setOutPath(state.store->printStorePath(outputs.at("out")));
if (name.size() >= drvExtension.size() &&
string(name, name.size() - drvExtension.size()) == drvExtension)
name = string(name, 0, name.size() - drvExtension.size());
Expand Down

0 comments on commit 2274f63

Please sign in to comment.