diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-08-30 12:23:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-30 12:23:09 +0200 |
commit | 323cafcb4ec632881c297f9b3004ea7fb07b678f (patch) | |
tree | a83b133815dfa21a7489aa0d1d02ce31e17adca5 /src | |
parent | 00f9957552180ef44fe5fab98f7d09cd15d99506 (diff) | |
parent | 8656b130ea6defe6a7ef04b564ff391caa64a450 (diff) |
Merge pull request #5191 from hercules-ci/evalstate-lifetime-hygiene
EvalState lifetime hygiene
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/eval.hh | 2 | ||||
-rw-r--r-- | src/libexpr/flake/flake.cc | 10 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 11 |
3 files changed, 11 insertions, 12 deletions
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index f3684db79..0fced795d 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -100,6 +100,8 @@ public: /* Store used to build stuff. */ const ref<Store> buildStore; + RootValue vCallFlake = nullptr; + RootValue vImportedDrvToDerivation = nullptr; private: SrcToStore srcToStore; diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 9e00ff188..ee345bdbc 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -663,16 +663,14 @@ void callFlake(EvalState & state, mkString(*vRootSubdir, lockedFlake.flake.lockedRef.subdir); - static RootValue vCallFlake = nullptr; - - if (!vCallFlake) { - vCallFlake = allocRootValue(state.allocValue()); + if (!state.vCallFlake) { + state.vCallFlake = allocRootValue(state.allocValue()); state.eval(state.parseExprFromString( #include "call-flake.nix.gen.hh" - , "/"), **vCallFlake); + , "/"), **state.vCallFlake); } - state.callFunction(**vCallFlake, *vLocks, *vTmp1, noPos); + state.callFunction(**state.vCallFlake, *vLocks, *vTmp1, noPos); state.callFunction(*vTmp1, *vRootSrc, *vTmp2, noPos); state.callFunction(*vTmp2, *vRootSubdir, vRes, noPos); } diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 2295e69a1..25d60e175 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -160,16 +160,15 @@ static void import(EvalState & state, const Pos & pos, Value & vPath, Value * vS } w.attrs->sort(); - static RootValue fun; - if (!fun) { - fun = allocRootValue(state.allocValue()); + if (!state.vImportedDrvToDerivation) { + state.vImportedDrvToDerivation = allocRootValue(state.allocValue()); state.eval(state.parseExprFromString( #include "imported-drv-to-derivation.nix.gen.hh" - , "/"), **fun); + , "/"), **state.vImportedDrvToDerivation); } - state.forceFunction(**fun, pos); - mkApp(v, **fun, w); + state.forceFunction(**state.vImportedDrvToDerivation, pos); + mkApp(v, **state.vImportedDrvToDerivation, w); state.forceAttrs(v, pos); } |