1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 11:43:15 +02:00

Restore subdir support in registries

Hacky...
This commit is contained in:
Eelco Dolstra 2020-02-20 22:14:44 +01:00
parent 890df325c7
commit d068f9ffff
6 changed files with 60 additions and 31 deletions

View file

@ -42,9 +42,11 @@ MixEvalArgs::MixEvalArgs()
.description("override a flake registry value")
.arity(2)
.handler([&](std::vector<std::string> ss) {
fetchers::overrideRegistry(
parseFlakeRef(ss[0], absPath(".")).input,
parseFlakeRef(ss[1], absPath(".")).input);
auto from = parseFlakeRef(ss[0], absPath("."));
auto to = parseFlakeRef(ss[1], absPath("."));
fetchers::Input::Attrs extraAttrs;
if (to.subdir != "") extraAttrs["subdir"] = to.subdir;
fetchers::overrideRegistry(from.input, to.input, extraAttrs);
});
}

View file

@ -40,7 +40,8 @@ bool FlakeRef::operator ==(const FlakeRef & other) const
FlakeRef FlakeRef::resolve(ref<Store> store) const
{
return FlakeRef(lookupInRegistries(store, input), subdir);
auto [input2, extraAttrs] = lookupInRegistries(store, input);
return FlakeRef(input2, fetchers::maybeGetStrAttr(extraAttrs, "subdir").value_or(subdir));
}
FlakeRef parseFlakeRef(

View file

@ -36,7 +36,7 @@ static void prim_fetchTree(EvalState & state, const Pos & pos, Value * * args, V
input = fetchers::inputFromURL(state.coerceToString(pos, *args[0], context, false, false));
if (!evalSettings.pureEval && !input->isDirect())
input = lookupInRegistries(state.store, input);
input = lookupInRegistries(state.store, input).first;
if (evalSettings.pureEval && !input->isImmutable())
throw Error("in pure evaluation mode, 'fetchTree' requires an immutable input");