Skip to content

Commit d926bcd

Browse files
authored
Merge pull request #337 from Ericson2314/ca-output-json-null
Make fallback logic for CA derivations more flexible
2 parents f2ccb7e + e721d7a commit d926bcd

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/drv.cc

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,36 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state,
7878
// fallback if we encounter an error
7979
try {
8080
outputsQueried = packageInfo.queryOutputs(true);
81-
} catch (const nix::UnimplementedError &e) {
81+
} catch (const nix::Error &e) {
82+
// We could be hitting `nix::UnimplementedError`:
83+
// https://github.com/NixOS/nix/blob/39da9462e9c677026a805c5ee7ba6bb306f49c59/src/libexpr/get-drvs.cc#L106
84+
//
85+
// Or we could be hitting:
86+
// ```
87+
// error: derivation 'caDependingOnCA' does not have valid outputs:
88+
// error: while evaluating the output path of a derivation at
89+
// <nix/derivation-internal.nix>:19:9:
90+
//
91+
// 18| value = commonAttrs // {
92+
// 19| outPath = builtins.getAttr outputName strict;\n
93+
// | ^
94+
// 20| drvPath = strict.drvPath;
95+
//
96+
// error: path
97+
// '/0rmq7bvk2raajd310spvd416f2jajrabcg6ar706gjbd6b8nmvks' is not in
98+
// the Nix store
99+
// ```
100+
// i.e. the placeholders were confusing it.
101+
//
102+
// FIXME: a better fix would be in Nix to first check if
103+
// `outPath` is equal to the placeholder. See
104+
// https://github.com/NixOS/nix/issues/11885.
82105
if (!nix::experimentalFeatureSettings.isEnabled(
83106
nix::Xp::CaDerivations)) {
84107
// If we do have CA derivations enabled, we should not encounter
85-
// this error.
108+
// these errors.
86109
throw;
87110
}
88-
// we are probably hitting this:
89-
// https://github.com/NixOS/nix/blob/39da9462e9c677026a805c5ee7ba6bb306f49c59/src/libexpr/get-drvs.cc#L106
90111
outputsQueried = packageInfo.queryOutputs(false);
91112
}
92113
for (auto &[outputName, optOutputPath] : outputsQueried) {

0 commit comments

Comments
 (0)