From a291e37b20efa54c6a5f3394a01dfc42881b0478 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 28 Sep 2022 15:09:24 +0200 Subject: [PATCH] Improve error messages from call-flake.nix --- src/libexpr/eval.cc | 6 ++++++ src/libexpr/eval.hh | 4 +++- src/libexpr/flake/flake.cc | 10 +++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 9ec6b04c6..bfe6c01dd 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -477,10 +477,15 @@ EvalState::EvalState( throw RestrictedPathError("access to absolute path '%1%' is forbidden %2%", path, modeInformation); })) , corepkgsFS(makeMemoryInputAccessor()) + , internalFS(makeMemoryInputAccessor()) , derivationInternal{corepkgsFS->addFile( CanonPath("derivation-internal.nix"), #include "primops/derivation.nix.gen.hh" )} + , callFlakeInternal{internalFS->addFile( + CanonPath("call-flake.nix"), + #include "flake/call-flake.nix.gen.hh" + )} , store(store) , buildStore(buildStore ? buildStore : store) , debugRepl(nullptr) @@ -499,6 +504,7 @@ EvalState::EvalState( , staticBaseEnv{std::make_shared(false, nullptr)} { corepkgsFS->setPathDisplay(""); + internalFS->setPathDisplay("«nix-internal»", ""); countCalls = getEnv("NIX_COUNT_CALLS").value_or("0") != "0"; diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 390b79617..2fb6a74c9 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -111,9 +111,12 @@ public: const ref rootFS; const ref corepkgsFS; + const ref internalFS; const SourcePath derivationInternal; + const SourcePath callFlakeInternal; + /* A map keyed by InputAccessor::number that keeps input accessors alive. */ std::unordered_map> inputAccessors; @@ -124,7 +127,6 @@ public: /* Store used to build stuff. */ const ref buildStore; - RootValue vCallFlake = nullptr; RootValue vImportedDrvToDerivation = nullptr; /* Debugger */ diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 07fb75fd5..82adda4a7 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -704,14 +704,10 @@ void callFlake(EvalState & state, vRootSubdir->mkString(lockedFlake.flake.lockedRef.subdir); - if (!state.vCallFlake) { - state.vCallFlake = allocRootValue(state.allocValue()); - state.eval(state.parseExprFromString( - #include "call-flake.nix.gen.hh" - , state.rootPath("/")), **state.vCallFlake); - } + Value vCallFlake; + state.evalFile(state.callFlakeInternal, vCallFlake); - state.callFunction(**state.vCallFlake, *vLocks, *vTmp1, noPos); + state.callFunction(vCallFlake, *vLocks, *vTmp1, noPos); state.callFunction(*vTmp1, *vRootSrc, *vTmp2, noPos); state.callFunction(*vTmp2, *vRootSubdir, vRes, noPos); }