forked from lix-project/nix-eval-jobs
Fix compilation for latest Lix main
This commit is contained in:
parent
dfc286ca3d
commit
bdbe3e1304
14
flake.lock
14
flake.lock
|
@ -47,11 +47,11 @@
|
||||||
"pre-commit-hooks": "pre-commit-hooks"
|
"pre-commit-hooks": "pre-commit-hooks"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1732112222,
|
"lastModified": 1733448312,
|
||||||
"narHash": "sha256-H7GN4++a4vE49SUNojZx+FSk4mmpb2ifJUtJMJHProI=",
|
"narHash": "sha256-id5U81bzXk/Lg900nGLM4CQb0wmTdzIvQz7CZk2OcTM=",
|
||||||
"rev": "66f6dbda32959dd5cf3a9aaba15af72d037ab7ff",
|
"rev": "2a9e560570982a91937d199af3e7b7a8f3cbe14b",
|
||||||
"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/2a9e560570982a91937d199af3e7b7a8f3cbe14b.tar.gz?rev=2a9e560570982a91937d199af3e7b7a8f3cbe14b"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
|
@ -96,11 +96,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1732244845,
|
"lastModified": 1733408989,
|
||||||
"narHash": "sha256-aspop5sCDNpDMS23BplGFtQDadwkSb/sOxpuC3lafvo=",
|
"narHash": "sha256-VCQpCQy+6ik+oYKWUCvq0WM2V7UtEKldqdsEzCNEOLc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "df94f897ffe1af1bcd60cb68697c5d8e6431346e",
|
"rev": "d916387b68a74040a3873ad2a08a559c60cedb5e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
19
src/drv.cc
19
src/drv.cc
|
@ -45,13 +45,13 @@ queryIsCached(nix::Store &store,
|
||||||
Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
|
Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
|
||||||
MyArgs &args) {
|
MyArgs &args) {
|
||||||
|
|
||||||
auto localStore = state.store.dynamic_pointer_cast<nix::LocalFSStore>();
|
auto localStore = state.ctx.store.dynamic_pointer_cast<nix::LocalFSStore>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// CA derivations do not have static output paths, so we have to
|
// CA derivations do not have static output paths, so we have to
|
||||||
// defensively not query output paths in case we encounter one.
|
// defensively not query output paths in case we encounter one.
|
||||||
for (auto &[outputName, optOutputPath] :
|
for (auto &[outputName, optOutputPath] :
|
||||||
drvInfo.queryOutputs(!nix::experimentalFeatureSettings.isEnabled(
|
drvInfo.queryOutputs(state, !nix::experimentalFeatureSettings.isEnabled(
|
||||||
nix::Xp::CaDerivations))) {
|
nix::Xp::CaDerivations))) {
|
||||||
if (optOutputPath) {
|
if (optOutputPath) {
|
||||||
outputs[outputName] =
|
outputs[outputName] =
|
||||||
|
@ -63,18 +63,19 @@ 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,
|
state.ctx.errors.make<nix::EvalError>(
|
||||||
"derivation '%s' does not have valid outputs: %s",
|
"derivation '%s' does not have valid outputs: %s",
|
||||||
attrPath, e.what());
|
attrPath, e.what()
|
||||||
|
).debugThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.meta) {
|
if (args.meta) {
|
||||||
nlohmann::json meta_;
|
nlohmann::json meta_;
|
||||||
for (auto &metaName : drvInfo.queryMetaNames()) {
|
for (auto &metaName : drvInfo.queryMetaNames(state)) {
|
||||||
nix::NixStringContext context;
|
nix::NixStringContext context;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
auto metaValue = drvInfo.queryMeta(metaName);
|
auto metaValue = drvInfo.queryMeta(state, metaName);
|
||||||
// Skip non-serialisable types
|
// Skip non-serialisable types
|
||||||
// TODO: Fix serialisation of derivations to store paths
|
// TODO: Fix serialisation of derivations to store paths
|
||||||
if (metaValue == 0) {
|
if (metaValue == 0) {
|
||||||
|
@ -96,9 +97,9 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
|
||||||
cacheStatus = Drv::CacheStatus::Unknown;
|
cacheStatus = Drv::CacheStatus::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
drvPath = localStore->printStorePath(drvInfo.requireDrvPath());
|
drvPath = localStore->printStorePath(drvInfo.requireDrvPath(state));
|
||||||
|
|
||||||
auto drv = localStore->readDerivation(drvInfo.requireDrvPath());
|
auto drv = localStore->readDerivation(drvInfo.requireDrvPath(state));
|
||||||
for (const auto &[inputDrvPath, inputNode] : drv.inputDrvs.map) {
|
for (const auto &[inputDrvPath, inputNode] : drv.inputDrvs.map) {
|
||||||
std::set<std::string> inputDrvOutputs;
|
std::set<std::string> inputDrvOutputs;
|
||||||
for (auto &outputName : inputNode.value) {
|
for (auto &outputName : inputNode.value) {
|
||||||
|
@ -106,7 +107,7 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
|
||||||
}
|
}
|
||||||
inputDrvs[localStore->printStorePath(inputDrvPath)] = inputDrvOutputs;
|
inputDrvs[localStore->printStorePath(inputDrvPath)] = inputDrvOutputs;
|
||||||
}
|
}
|
||||||
name = drvInfo.queryName();
|
name = drvInfo.queryName(state);
|
||||||
system = drv.platform;
|
system = drv.platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <nlohmann/json_fwd.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
#include <lix/libutil/ref.hh>
|
#include <lix/libutil/ref.hh>
|
||||||
#include <lix/libstore/store-api.hh>
|
#include <lix/libstore/store-api.hh>
|
||||||
#include <map>
|
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
@ -47,9 +46,8 @@ using namespace nlohmann;
|
||||||
|
|
||||||
static MyArgs myArgs;
|
static MyArgs myArgs;
|
||||||
|
|
||||||
typedef std::function<void(ref<EvalState> state, Bindings &autoArgs,
|
using Processor = std::function<void(ref<nix::eval_cache::CachingEvaluator> state, Bindings &autoArgs,
|
||||||
AutoCloseFD &to, AutoCloseFD &from, MyArgs &args)>
|
AutoCloseFD &to, AutoCloseFD &from, MyArgs &args)>;
|
||||||
Processor;
|
|
||||||
|
|
||||||
/* Auto-cleanup of fork's process and fds. */
|
/* Auto-cleanup of fork's process and fds. */
|
||||||
struct Proc {
|
struct Proc {
|
||||||
|
@ -70,10 +68,10 @@ 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 evaluator = nix::make_ref<nix::eval_cache::CachingEvaluator>(myArgs.searchPath,
|
||||||
evalStore);
|
evalStore);
|
||||||
Bindings &autoArgs = *myArgs.getAutoArgs(*state);
|
Bindings &autoArgs = *myArgs.getAutoArgs(*evaluator);
|
||||||
proc(ref<EvalState>(state), autoArgs, *to, *from, myArgs);
|
proc(evaluator, autoArgs, *to, *from, myArgs);
|
||||||
} catch (Error &e) {
|
} catch (Error &e) {
|
||||||
nlohmann::json err;
|
nlohmann::json err;
|
||||||
auto msg = e.msg();
|
auto msg = e.msg();
|
||||||
|
|
|
@ -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>
|
||||||
|
@ -48,14 +49,14 @@ static nix::Value *releaseExprTopLevelValue(nix::EvalState &state,
|
||||||
nix::Value vTop;
|
nix::Value vTop;
|
||||||
|
|
||||||
if (args.fromArgs) {
|
if (args.fromArgs) {
|
||||||
nix::Expr &e = state.parseExprFromString(
|
nix::Expr &e = state.ctx.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(nix::lookupFileArg(state.ctx, args.releaseExpr), vTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto vRoot = state.allocValue();
|
auto vRoot = state.ctx.mem.allocValue();
|
||||||
|
|
||||||
state.autoCallFunction(autoArgs, vTop, *vRoot);
|
state.autoCallFunction(autoArgs, vTop, *vRoot);
|
||||||
|
|
||||||
|
@ -73,16 +74,17 @@ static std::string attrPathJoin(nlohmann::json input) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs,
|
void worker(nix::ref<nix::eval_cache::CachingEvaluator> evaluator, nix::Bindings &autoArgs,
|
||||||
nix::AutoCloseFD &to, nix::AutoCloseFD &from, MyArgs &args) {
|
nix::AutoCloseFD &to, nix::AutoCloseFD &from, MyArgs &args) {
|
||||||
|
|
||||||
nix::Value *vRoot = [&]() {
|
nix::Value *vRoot = [&]() {
|
||||||
|
auto state = evaluator->begin();
|
||||||
if (args.flake) {
|
if (args.flake) {
|
||||||
auto [flakeRef, fragment, outputSpec] =
|
auto [flakeRef, fragment, outputSpec] =
|
||||||
nix::parseFlakeRefWithFragmentAndExtendedOutputsSpec(
|
nix::parseFlakeRefWithFragmentAndExtendedOutputsSpec(
|
||||||
args.releaseExpr, nix::absPath("."));
|
args.releaseExpr, nix::absPath("."));
|
||||||
nix::InstallableFlake flake{
|
nix::InstallableFlake flake{
|
||||||
{}, state, std::move(flakeRef), fragment, outputSpec,
|
{}, evaluator, std::move(flakeRef), fragment, outputSpec,
|
||||||
{}, {}, args.lockFlags};
|
{}, {}, args.lockFlags};
|
||||||
|
|
||||||
return flake.toValue(*state).first;
|
return flake.toValue(*state).first;
|
||||||
|
@ -92,6 +94,7 @@ void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs,
|
||||||
}();
|
}();
|
||||||
|
|
||||||
LineReader fromReader(from.release());
|
LineReader fromReader(from.release());
|
||||||
|
auto state = evaluator->begin();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/* Wait for the collector to send us a job name. */
|
/* Wait for the collector to send us a job name. */
|
||||||
|
@ -119,7 +122,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 = evaluator->mem.allocValue();
|
||||||
state->autoCallFunction(autoArgs, *vTmp, *v);
|
state->autoCallFunction(autoArgs, *vTmp, *v);
|
||||||
|
|
||||||
if (v->type() == nix::nAttrs) {
|
if (v->type() == nix::nAttrs) {
|
||||||
|
@ -136,7 +139,7 @@ void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs,
|
||||||
std::string(nix::baseNameOf(drv.drvPath));
|
std::string(nix::baseNameOf(drv.drvPath));
|
||||||
if (!nix::pathExists(root)) {
|
if (!nix::pathExists(root)) {
|
||||||
auto localStore =
|
auto localStore =
|
||||||
state->store
|
evaluator->store
|
||||||
.dynamic_pointer_cast<nix::LocalFSStore>();
|
.dynamic_pointer_cast<nix::LocalFSStore>();
|
||||||
auto storePath =
|
auto storePath =
|
||||||
localStore->parseStorePath(drv.drvPath);
|
localStore->parseStorePath(drv.drvPath);
|
||||||
|
@ -151,14 +154,14 @@ void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs,
|
||||||
// = true;` for top-level attrset
|
// = true;` for top-level attrset
|
||||||
|
|
||||||
for (auto &i :
|
for (auto &i :
|
||||||
v->attrs->lexicographicOrder(state->symbols)) {
|
v->attrs->lexicographicOrder(evaluator->symbols)) {
|
||||||
const std::string &name = state->symbols[i->name];
|
const std::string &name = evaluator->symbols[i->name];
|
||||||
attrs.push_back(name);
|
attrs.push_back(name);
|
||||||
|
|
||||||
if (name == "recurseForDerivations" &&
|
if (name == "recurseForDerivations" &&
|
||||||
!args.forceRecurse) {
|
!args.forceRecurse) {
|
||||||
auto attrv =
|
auto attrv =
|
||||||
v->attrs->get(state->sRecurseForDerivations);
|
v->attrs->get(evaluator->s.recurseForDerivations);
|
||||||
recurse = state->forceBool(
|
recurse = state->forceBool(
|
||||||
*attrv->value, attrv->pos,
|
*attrv->value, attrv->pos,
|
||||||
"while evaluating recurseForDerivations");
|
"while evaluating recurseForDerivations");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <lix/libmain/shared.hh>
|
#include <lix/libmain/shared.hh>
|
||||||
#include <lix/libexpr/eval.hh>
|
#include <lix/libexpr/eval.hh>
|
||||||
|
#include <lix/libexpr/eval-cache.hh>
|
||||||
|
|
||||||
#include "eval-args.hh"
|
#include "eval-args.hh"
|
||||||
|
|
||||||
|
@ -13,5 +14,5 @@ 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::CachingEvaluator> evaluator, nix::Bindings &autoArgs,
|
||||||
nix::AutoCloseFD &to, nix::AutoCloseFD &from, MyArgs &args);
|
nix::AutoCloseFD &to, nix::AutoCloseFD &from, MyArgs &args);
|
||||||
|
|
Loading…
Reference in a new issue