@@ -85,7 +85,6 @@ static void parseFlakeInputAttr(
85
85
86
86
static FlakeInput parseFlakeInput (
87
87
EvalState & state,
88
- std::string_view inputName,
89
88
Value * value,
90
89
const PosIdx pos,
91
90
const InputAttrPath & lockRootAttrPath,
@@ -155,8 +154,8 @@ static FlakeInput parseFlakeInput(
155
154
input.ref = parseFlakeRef (state.fetchSettings , *url, {}, true , input.isFlake , true );
156
155
}
157
156
158
- if (! input.follows && ! input.ref )
159
- input. ref = FlakeRef::fromAttrs (state. fetchSettings , {{ " type " , " indirect " }, { " id " , std::string (inputName)}} );
157
+ if (input.ref && input.follows )
158
+ throw Error ( " flake input has both a flake reference and a follows attribute, at %s " , state. positions [pos] );
160
159
161
160
return input;
162
161
}
@@ -185,7 +184,6 @@ static std::pair<std::map<FlakeId, FlakeInput>, fetchers::Attrs> parseFlakeInput
185
184
} else {
186
185
inputs.emplace (inputName,
187
186
parseFlakeInput (state,
188
- inputName,
189
187
inputAttr.value ,
190
188
inputAttr.pos ,
191
189
lockRootAttrPath,
@@ -467,18 +465,27 @@ LockedFlake lockFlake(
467
465
468
466
/* Get the overrides (i.e. attributes of the form
469
467
'inputs.nixops.inputs.nixpkgs.url = ...'). */
470
- for (auto & [id, input] : flakeInputs) {
468
+ std::function<void (const FlakeInput & input, const InputAttrPath & prefix)> addOverrides;
469
+ addOverrides = [&](const FlakeInput & input, const InputAttrPath & prefix)
470
+ {
471
471
for (auto & [idOverride, inputOverride] : input.overrides ) {
472
- auto inputAttrPath (inputAttrPathPrefix);
473
- inputAttrPath.push_back (id);
472
+ auto inputAttrPath (prefix);
474
473
inputAttrPath.push_back (idOverride);
475
- overrides.emplace (inputAttrPath,
476
- OverrideTarget {
477
- .input = inputOverride,
478
- .sourcePath = sourcePath,
479
- .parentInputAttrPath = inputAttrPathPrefix
480
- });
474
+ if (inputOverride.ref || inputOverride.follows )
475
+ overrides.emplace (inputAttrPath,
476
+ OverrideTarget {
477
+ .input = inputOverride,
478
+ .sourcePath = sourcePath,
479
+ .parentInputAttrPath = inputAttrPathPrefix
480
+ });
481
+ addOverrides (inputOverride, inputAttrPath);
481
482
}
483
+ };
484
+
485
+ for (auto & [id, input] : flakeInputs) {
486
+ auto inputAttrPath (inputAttrPathPrefix);
487
+ inputAttrPath.push_back (id);
488
+ addOverrides (input, inputAttrPath);
482
489
}
483
490
484
491
/* Check whether this input has overrides for a
@@ -534,7 +541,8 @@ LockedFlake lockFlake(
534
541
continue ;
535
542
}
536
543
537
- assert (input.ref );
544
+ if (!input.ref )
545
+ input.ref = FlakeRef::fromAttrs (state.fetchSettings , {{" type" , " indirect" }, {" id" , std::string (id)}});
538
546
539
547
auto overridenParentPath =
540
548
input.ref ->input .isRelative ()
0 commit comments