Compare commits

..

1 Commits

Author SHA1 Message Date
Eelco Dolstra
ffc6252e36 Expose builtins.fetchFinalTree to the user
This may be more efficient than fetchTree since it allows substitution
from binary caches if `narHash` is specified in the input
attributes. This is what call-flake.nix already used internally.
2025-11-24 19:56:05 +01:00
3 changed files with 7 additions and 10 deletions

View File

@@ -362,10 +362,13 @@ void prim_fetchFinalTree(EvalState & state, const PosIdx pos, Value ** args, Val
}
static RegisterPrimOp primop_fetchFinalTree({
.name = "fetchFinalTree",
.name = "__fetchFinalTree",
.args = {"input"},
.doc = R"(
Like `fetchTree`, but does not return any additional fetcher attributes (like `revCount`).
This allows inputs to be substituted if `narHash` is specified.
)",
.fun = prim_fetchFinalTree,
.internal = true,
});
static void fetch(

View File

@@ -10,9 +10,6 @@ lockFileStr:
# unlocked trees.
overrides:
# This is `prim_fetchFinalTree`.
fetchTreeFinal:
let
inherit (builtins) mapAttrs;
@@ -52,7 +49,7 @@ let
else
# FIXME: remove obsolete node.info.
# Note: lock file entries are always final.
fetchTreeFinal (node.info or { } // removeAttrs node.locked [ "dir" ]);
builtins.fetchFinalTree (node.info or { } // removeAttrs node.locked [ "dir" ]);
subdir = overrides.${key}.dir or node.locked.dir or "";

View File

@@ -968,10 +968,7 @@ void callFlake(EvalState & state, const LockedFlake & lockedFlake, Value & vRes)
auto vLocks = state.allocValue();
vLocks->mkString(lockFileStr, state.mem);
auto vFetchFinalTree = get(state.internalPrimOps, "fetchFinalTree");
assert(vFetchFinalTree);
Value * args[] = {vLocks, &vOverrides, *vFetchFinalTree};
Value * args[] = {vLocks, &vOverrides};
state.callFunction(*vCallFlake, args, vRes, noPos);
}