@@ -90,11 +90,11 @@ static void expectType(EvalState & state, ValueType type,
90
90
91
91
static std::map<FlakeId, FlakeInput> parseFlakeInputs (
92
92
EvalState & state, Value * value, const PosIdx pos,
93
- const std::optional<Path> & baseDir, InputPath lockRootPath, unsigned depth );
93
+ const std::optional<Path> & baseDir, InputPath lockRootPath);
94
94
95
95
static FlakeInput parseFlakeInput (EvalState & state,
96
96
const std::string & inputName, Value * value, const PosIdx pos,
97
- const std::optional<Path> & baseDir, InputPath lockRootPath, unsigned depth )
97
+ const std::optional<Path> & baseDir, InputPath lockRootPath)
98
98
{
99
99
expectType (state, nAttrs, *value, pos);
100
100
@@ -118,7 +118,7 @@ static FlakeInput parseFlakeInput(EvalState & state,
118
118
expectType (state, nBool, *attr.value , attr.pos );
119
119
input.isFlake = attr.value ->boolean ;
120
120
} else if (attr.name == sInputs ) {
121
- input.overrides = parseFlakeInputs (state, attr.value , attr.pos , baseDir, lockRootPath, depth + 1 );
121
+ input.overrides = parseFlakeInputs (state, attr.value , attr.pos , baseDir, lockRootPath);
122
122
} else if (attr.name == sFollows ) {
123
123
expectType (state, nString, *attr.value , attr.pos );
124
124
auto follows (parseInputPath (attr.value ->string .s ));
@@ -163,19 +163,15 @@ static FlakeInput parseFlakeInput(EvalState & state,
163
163
input.ref = parseFlakeRef (*url, baseDir, true , input.isFlake );
164
164
}
165
165
166
- if (!input.follows && !input.ref && depth == 0 )
167
- // in `input.nixops.inputs.nixpkgs.url = ...`, we assume `nixops` is from
168
- // the flake registry absent `ref`/`follows`, but we should not assume so
169
- // about `nixpkgs` (where `depth == 1`) as the `nixops` flake should
170
- // determine its default source
166
+ if (!input.follows && !input.ref )
171
167
input.ref = FlakeRef::fromAttrs ({{" type" , " indirect" }, {" id" , inputName}});
172
168
173
169
return input;
174
170
}
175
171
176
172
static std::map<FlakeId, FlakeInput> parseFlakeInputs (
177
173
EvalState & state, Value * value, const PosIdx pos,
178
- const std::optional<Path> & baseDir, InputPath lockRootPath, unsigned depth )
174
+ const std::optional<Path> & baseDir, InputPath lockRootPath)
179
175
{
180
176
std::map<FlakeId, FlakeInput> inputs;
181
177
@@ -188,8 +184,7 @@ static std::map<FlakeId, FlakeInput> parseFlakeInputs(
188
184
inputAttr.value ,
189
185
inputAttr.pos ,
190
186
baseDir,
191
- lockRootPath,
192
- depth));
187
+ lockRootPath));
193
188
}
194
189
195
190
return inputs;
@@ -235,7 +230,7 @@ static Flake getFlake(
235
230
auto sInputs = state.symbols .create (" inputs" );
236
231
237
232
if (auto inputs = vInfo.attrs ->get (sInputs ))
238
- flake.inputs = parseFlakeInputs (state, inputs->value , inputs->pos , flakeDir, lockRootPath, 0 );
233
+ flake.inputs = parseFlakeInputs (state, inputs->value , inputs->pos , flakeDir, lockRootPath);
239
234
240
235
auto sOutputs = state.symbols .create (" outputs" );
241
236
@@ -318,19 +313,6 @@ Flake getFlake(EvalState & state, const FlakeRef & originalRef, bool allowLookup
318
313
return getFlake (state, originalRef, allowLookup, flakeCache);
319
314
}
320
315
321
- /* Recursively merge `overrides` into `overrideMap` */
322
- static void updateOverrides (std::map<InputPath, FlakeInput> & overrideMap, const FlakeInputs & overrides,
323
- const InputPath & inputPathPrefix)
324
- {
325
- for (auto & [id, input] : overrides) {
326
- auto inputPath (inputPathPrefix);
327
- inputPath.push_back (id);
328
- // Do not override existing assignment from outer flake
329
- overrideMap.insert ({inputPath, input});
330
- updateOverrides (overrideMap, input.overrides , inputPath);
331
- }
332
- }
333
-
334
316
/* Compute an in-memory lock file for the specified top-level flake,
335
317
and optionally write it to file, if the flake is writable. */
336
318
LockedFlake lockFlake (
@@ -393,9 +375,12 @@ LockedFlake lockFlake(
393
375
/* Get the overrides (i.e. attributes of the form
394
376
'inputs.nixops.inputs.nixpkgs.url = ...'). */
395
377
for (auto & [id, input] : flakeInputs) {
396
- auto inputPath (inputPathPrefix);
397
- inputPath.push_back (id);
398
- updateOverrides (overrides, input.overrides , inputPath);
378
+ for (auto & [idOverride, inputOverride] : input.overrides ) {
379
+ auto inputPath (inputPathPrefix);
380
+ inputPath.push_back (id);
381
+ inputPath.push_back (idOverride);
382
+ overrides.insert_or_assign (inputPath, inputOverride);
383
+ }
399
384
}
400
385
401
386
/* Check whether this input has overrides for a
@@ -430,12 +415,6 @@ LockedFlake lockFlake(
430
415
// Respect the “flakeness” of the input even if we
431
416
// override it
432
417
i->second .isFlake = input2.isFlake ;
433
- if (!i->second .ref )
434
- i->second .ref = input2.ref ;
435
- if (!i->second .follows )
436
- i->second .follows = input2.follows ;
437
- // Note that `input.overrides` is not used in the following,
438
- // so no need to merge it here (already done by `updateOverrides`)
439
418
}
440
419
auto & input = hasOverride ? i->second : input2;
441
420
0 commit comments