1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-18 16:29:36 +01:00

Move call-flake.nix to nix-flake

As suggested by Ericson2314 in review
https://github.com/NixOS/nix/pull/12759#issuecomment-2755352343

(cherry picked from commit 0c75581d8b)
This commit is contained in:
Robert Hensing 2025-03-26 20:02:06 +00:00 committed by Mergify
parent 9dfadd3694
commit 5663827c7d
7 changed files with 34 additions and 10 deletions

View file

@ -16,6 +16,8 @@
#include <nlohmann/json.hpp>
#include "memory-source-accessor.hh"
namespace nix {
using namespace flake;
@ -921,6 +923,25 @@ LockedFlake lockFlake(
}
}
static ref<SourceAccessor> makeInternalFS() {
auto internalFS = make_ref<MemorySourceAccessor>(MemorySourceAccessor {});
internalFS->setPathDisplay("«flakes-internal»", "");
internalFS->addFile(
CanonPath("call-flake.nix"),
#include "call-flake.nix.gen.hh"
);
return internalFS;
}
static auto internalFS = makeInternalFS();
static Value * requireInternalFile(EvalState & state, CanonPath path) {
SourcePath p {internalFS, path};
auto v = state.allocValue();
state.evalFile(p, *v); // has caching
return v;
}
void callFlake(EvalState & state,
const LockedFlake & lockedFlake,
Value & vRes)
@ -960,8 +981,7 @@ void callFlake(EvalState & state,
auto & vOverrides = state.allocValue()->mkAttrs(overrides);
auto vCallFlake = state.allocValue();
state.evalFile(state.callFlakeInternal, *vCallFlake);
Value * vCallFlake = requireInternalFile(state, CanonPath("call-flake.nix"));
auto vLocks = state.allocValue();
vLocks->mkString(lockFileStr);