update lix

This commit is contained in:
leo60228 2024-11-29 16:52:37 -05:00 committed by Maximilian Bosch
parent 76f32ed29e
commit 9c5c88d57b
Signed by: ma27
SSH key fingerprint: SHA256:d7dmwHmpai66L6KIXA+wxzVbkPq0nGLrcHK3ZNroqZY
5 changed files with 26 additions and 20 deletions

View file

@ -47,11 +47,11 @@
"pre-commit-hooks": "pre-commit-hooks" "pre-commit-hooks": "pre-commit-hooks"
}, },
"locked": { "locked": {
"lastModified": 1732112222, "lastModified": 1732899308,
"narHash": "sha256-H7GN4++a4vE49SUNojZx+FSk4mmpb2ifJUtJMJHProI=", "narHash": "sha256-1jsQqcbMbaWuFim3sqEUdB1/E2KqHa0+cHbTzd/GYFE=",
"rev": "66f6dbda32959dd5cf3a9aaba15af72d037ab7ff", "rev": "2e5780ebc848f3b021f11dd94533b0b68362d989",
"type": "tarball", "type": "tarball",
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/66f6dbda32959dd5cf3a9aaba15af72d037ab7ff.tar.gz?rev=66f6dbda32959dd5cf3a9aaba15af72d037ab7ff" "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2e5780ebc848f3b021f11dd94533b0b68362d989.tar.gz?rev=2e5780ebc848f3b021f11dd94533b0b68362d989"
}, },
"original": { "original": {
"type": "tarball", "type": "tarball",

View file

@ -63,8 +63,7 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
} }
} }
} catch (const std::exception &e) { } catch (const std::exception &e) {
throw nix::EvalError(state, throw nix::EvalError("derivation '%s' does not have valid outputs: %s",
"derivation '%s' does not have valid outputs: %s",
attrPath, e.what()); attrPath, e.what());
} }

View file

@ -5,6 +5,7 @@
#include <lix/libexpr/eval-settings.hh> #include <lix/libexpr/eval-settings.hh>
#include <lix/libmain/shared.hh> #include <lix/libmain/shared.hh>
#include <lix/libutil/sync.hh> #include <lix/libutil/sync.hh>
#include <lix/libexpr/eval-cache.hh>
#include <lix/libexpr/eval.hh> #include <lix/libexpr/eval.hh>
#include <lix/libutil/signals.hh> #include <lix/libutil/signals.hh>
#include <sys/wait.h> #include <sys/wait.h>
@ -49,8 +50,9 @@ using namespace nlohmann;
static MyArgs myArgs; static MyArgs myArgs;
typedef std::function<void(ref<EvalState> state, Bindings &autoArgs, typedef std::function<void(ref<eval_cache::CachingEvalState> state,
AutoCloseFD &to, AutoCloseFD &from, MyArgs &args)> Bindings &autoArgs, AutoCloseFD &to,
AutoCloseFD &from, MyArgs &args)>
Processor; Processor;
/* Auto-cleanup of fork's process and fds. */ /* Auto-cleanup of fork's process and fds. */
@ -72,10 +74,11 @@ struct Proc {
auto evalStore = myArgs.evalStoreUrl auto evalStore = myArgs.evalStoreUrl
? openStore(*myArgs.evalStoreUrl) ? openStore(*myArgs.evalStoreUrl)
: openStore(); : openStore();
auto state = std::make_shared<EvalState>(myArgs.searchPath, auto state = std::make_shared<eval_cache::CachingEvalState>(
evalStore); myArgs.searchPath, evalStore);
Bindings &autoArgs = *myArgs.getAutoArgs(*state); Bindings &autoArgs = *myArgs.getAutoArgs(*state);
proc(ref<EvalState>(state), autoArgs, *to, *from, myArgs); proc(ref<eval_cache::CachingEvalState>(state), autoArgs,
*to, *from, myArgs);
} catch (Error &e) { } catch (Error &e) {
nlohmann::json err; nlohmann::json err;
auto msg = e.msg(); auto msg = e.msg();

View file

@ -14,6 +14,7 @@
#include <lix/libutil/canon-path.hh> #include <lix/libutil/canon-path.hh>
#include <lix/libcmd/common-eval-args.hh> #include <lix/libcmd/common-eval-args.hh>
#include <lix/libutil/error.hh> #include <lix/libutil/error.hh>
#include <lix/libexpr/eval-cache.hh>
#include <lix/libexpr/eval-inline.hh> #include <lix/libexpr/eval-inline.hh>
#include <lix/libexpr/eval.hh> #include <lix/libexpr/eval.hh>
#include <lix/libexpr/flake/flakeref.hh> #include <lix/libexpr/flake/flakeref.hh>
@ -49,13 +50,13 @@ static nix::Value *releaseExprTopLevelValue(nix::EvalState &state,
if (args.fromArgs) { if (args.fromArgs) {
nix::Expr &e = state.parseExprFromString( nix::Expr &e = state.parseExprFromString(
args.releaseExpr, state.rootPath(nix::CanonPath::fromCwd())); args.releaseExpr, nix::CanonPath::fromCwd());
state.eval(e, vTop); state.eval(e, vTop);
} else { } else {
state.evalFile(lookupFileArg(state, args.releaseExpr), vTop); state.evalFile(lookupFileArg(state, args.releaseExpr), vTop);
} }
auto vRoot = state.allocValue(); auto vRoot = state.mem.allocValue();
state.autoCallFunction(autoArgs, vTop, *vRoot); state.autoCallFunction(autoArgs, vTop, *vRoot);
@ -73,8 +74,9 @@ static std::string attrPathJoin(nlohmann::json input) {
}); });
} }
void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs, void worker(nix::ref<nix::eval_cache::CachingEvalState> state,
nix::AutoCloseFD &to, nix::AutoCloseFD &from, MyArgs &args) { nix::Bindings &autoArgs, nix::AutoCloseFD &to,
nix::AutoCloseFD &from, MyArgs &args) {
nix::Value *vRoot = [&]() { nix::Value *vRoot = [&]() {
if (args.flake) { if (args.flake) {
@ -85,7 +87,7 @@ void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs,
{}, state, std::move(flakeRef), fragment, outputSpec, {}, state, std::move(flakeRef), fragment, outputSpec,
{}, {}, args.lockFlags}; {}, {}, args.lockFlags};
return flake.toValue(*state).first; return flake.toValue().first;
} else { } else {
return releaseExprTopLevelValue(*state, autoArgs, args); return releaseExprTopLevelValue(*state, autoArgs, args);
} }
@ -119,7 +121,7 @@ void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs,
nix::findAlongAttrPath(*state, attrPathS, autoArgs, *vRoot) nix::findAlongAttrPath(*state, attrPathS, autoArgs, *vRoot)
.first; .first;
auto v = state->allocValue(); auto v = state->mem.allocValue();
state->autoCallFunction(autoArgs, *vTmp, *v); state->autoCallFunction(autoArgs, *vTmp, *v);
if (v->type() == nix::nAttrs) { if (v->type() == nix::nAttrs) {
@ -191,7 +193,7 @@ void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs,
if (name == "recurseForDerivations" && if (name == "recurseForDerivations" &&
!args.forceRecurse) { !args.forceRecurse) {
auto attrv = auto attrv =
v->attrs->get(state->sRecurseForDerivations); v->attrs->get(state->s.recurseForDerivations);
recurse = state->forceBool( recurse = state->forceBool(
*attrv->value, attrv->pos, *attrv->value, attrv->pos,
"while evaluating recurseForDerivations"); "while evaluating recurseForDerivations");

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <lix/libmain/shared.hh> #include <lix/libmain/shared.hh>
#include <lix/libexpr/eval-cache.hh>
#include <lix/libexpr/eval.hh> #include <lix/libexpr/eval.hh>
#include "eval-args.hh" #include "eval-args.hh"
@ -13,5 +14,6 @@ class EvalState;
template <typename T> class ref; template <typename T> class ref;
} // namespace nix } // namespace nix
void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs, void worker(nix::ref<nix::eval_cache::CachingEvalState> state,
nix::AutoCloseFD &to, nix::AutoCloseFD &from, MyArgs &args); nix::Bindings &autoArgs, nix::AutoCloseFD &to,
nix::AutoCloseFD &from, MyArgs &args);