Skip to content

Commit

Permalink
Make nix shell fallback to static outputs when needed
Browse files Browse the repository at this point in the history
In case of pure input-addressed derivations, the build loop doesn't
guaranty that the realisations are stored in the db (if the output paths
are already there or can be substituted, the realisations won't be
registered). This caused `nix shell` to fail in some cases because it
was assuming that the realisations were always existing.

A better (but more involved) fix would probably to ensure that we always
register the realisations, but in the meantime this patches the surface
issue.

Fix #4721
  • Loading branch information
thufschmitt committed Apr 21, 2021
1 parent 8d651a1 commit 5d43cdb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/libcmd/installables.cc
Expand Up @@ -736,9 +736,14 @@ std::set<RealisedPath> toRealisedPaths(
output.first);
auto outputId = DrvOutput{outputHashes.at(output.first), output.first};
auto realisation = store->queryRealisation(outputId);
if (!realisation)
throw Error("cannot operate on an output of unbuilt content-addresed derivation '%s'", outputId.to_string());
res.insert(RealisedPath{*realisation});
if (!realisation) {
if (output.second)
res.insert(*output.second);
else
throw Error("cannot operate on an output of unbuilt content-addresed derivation '%s'", outputId.to_string());
} else {
res.insert(RealisedPath{*realisation});
}
}
else {
// If ca-derivations isn't enabled, behave as if
Expand Down

0 comments on commit 5d43cdb

Please sign in to comment.