Skip to content

Commit

Permalink
Merge pull request #337 from Ericson2314/ca-output-json-null
Browse files Browse the repository at this point in the history
Make fallback logic for CA derivations more flexible
  • Loading branch information
Mic92 authored Nov 15, 2024
2 parents f2ccb7e + e721d7a commit d926bcd
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/drv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,36 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state,
// fallback if we encounter an error
try {
outputsQueried = packageInfo.queryOutputs(true);
} catch (const nix::UnimplementedError &e) {
} catch (const nix::Error &e) {
// We could be hitting `nix::UnimplementedError`:
// https://github.com/NixOS/nix/blob/39da9462e9c677026a805c5ee7ba6bb306f49c59/src/libexpr/get-drvs.cc#L106
//
// Or we could be hitting:
// ```
// error: derivation 'caDependingOnCA' does not have valid outputs:
// error: while evaluating the output path of a derivation at
// <nix/derivation-internal.nix>:19:9:
//
// 18| value = commonAttrs // {
// 19| outPath = builtins.getAttr outputName strict;\n
// | ^
// 20| drvPath = strict.drvPath;
//
// error: path
// '/0rmq7bvk2raajd310spvd416f2jajrabcg6ar706gjbd6b8nmvks' is not in
// the Nix store
// ```
// i.e. the placeholders were confusing it.
//
// FIXME: a better fix would be in Nix to first check if
// `outPath` is equal to the placeholder. See
// https://github.com/NixOS/nix/issues/11885.
if (!nix::experimentalFeatureSettings.isEnabled(
nix::Xp::CaDerivations)) {
// If we do have CA derivations enabled, we should not encounter
// this error.
// these errors.
throw;
}
// we are probably hitting this:
// https://github.com/NixOS/nix/blob/39da9462e9c677026a805c5ee7ba6bb306f49c59/src/libexpr/get-drvs.cc#L106
outputsQueried = packageInfo.queryOutputs(false);
}
for (auto &[outputName, optOutputPath] : outputsQueried) {
Expand Down

0 comments on commit d926bcd

Please sign in to comment.