forked from lix-project/nix-eval-jobs
Compare commits
10 commits
Author | SHA1 | Date | |
---|---|---|---|
jade | df3edf3730 | ||
jade | bdbe3e1304 | ||
Maximilian Bosch | dfc286ca3d | ||
leo60228 | 912a9d6331 | ||
alois31 | bbbebaf380 | ||
alois31 | b9e0abe9e6 | ||
jade | 57ddb99e78 | ||
jade | 9160d40f80 | ||
Qyriad | 43aaa943bf | ||
Qyriad | 50a1455953 |
44
flake.lock
44
flake.lock
|
@ -23,11 +23,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722555600,
|
||||
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
|
||||
"lastModified": 1730504689,
|
||||
"narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
|
||||
"rev": "506278e768c2a08bec68eb62932193e341f55c90",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -47,11 +47,11 @@
|
|||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723577950,
|
||||
"narHash": "sha256-kOpGI9WPmte1L4QWHviuXsr8jxmGn27zwi82jtzYObM=",
|
||||
"rev": "b016eb0895bb6714a4f6530d9a2bb6577ac6c3cf",
|
||||
"lastModified": 1733448312,
|
||||
"narHash": "sha256-id5U81bzXk/Lg900nGLM4CQb0wmTdzIvQz7CZk2OcTM=",
|
||||
"rev": "2a9e560570982a91937d199af3e7b7a8f3cbe14b",
|
||||
"type": "tarball",
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/b016eb0895bb6714a4f6530d9a2bb6577ac6c3cf.tar.gz?rev=b016eb0895bb6714a4f6530d9a2bb6577ac6c3cf"
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2a9e560570982a91937d199af3e7b7a8f3cbe14b.tar.gz?rev=2a9e560570982a91937d199af3e7b7a8f3cbe14b"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
|
@ -65,11 +65,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1720066371,
|
||||
"narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=",
|
||||
"lastModified": 1731952509,
|
||||
"narHash": "sha256-p4gB3Rhw8R6Ak4eMl8pqjCPOLCZRqaehZxdZ/mbFClM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-github-actions",
|
||||
"rev": "622f829f5fe69310a866c8a6cd07e747c44ef820",
|
||||
"rev": "7b5f051df789b6b20d259924d349a9ba3319b226",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -81,11 +81,11 @@
|
|||
"nix2container": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1720642556,
|
||||
"narHash": "sha256-qsnqk13UmREKmRT7c8hEnz26X3GFFyIQrqx4EaRc1Is=",
|
||||
"lastModified": 1724996935,
|
||||
"narHash": "sha256-njRK9vvZ1JJsP8oV2OgkBrpJhgQezI03S7gzskCcHos=",
|
||||
"owner": "nlewo",
|
||||
"repo": "nix2container",
|
||||
"rev": "3853e5caf9ad24103b13aa6e0e8bcebb47649fe4",
|
||||
"rev": "fa6bb0a1159f55d071ba99331355955ae30b3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -96,11 +96,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1723540975,
|
||||
"narHash": "sha256-rxpxOz2VSqgmwI7g7FGVAoye5bxwO1MSpnELY5bsITw=",
|
||||
"lastModified": 1733408989,
|
||||
"narHash": "sha256-VCQpCQy+6ik+oYKWUCvq0WM2V7UtEKldqdsEzCNEOLc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fb81cec9eda2a6b5365ad723995f0329d9e356fd",
|
||||
"rev": "d916387b68a74040a3873ad2a08a559c60cedb5e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -129,11 +129,11 @@
|
|||
"pre-commit-hooks": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1721042469,
|
||||
"narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=",
|
||||
"lastModified": 1726745158,
|
||||
"narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "f451c19376071a90d8c58ab1a953c6e9840527fd",
|
||||
"rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -158,11 +158,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723454642,
|
||||
"narHash": "sha256-S0Gvsenh0II7EAaoc9158ZB4vYyuycvMGKGxIbERNAM=",
|
||||
"lastModified": 1732292307,
|
||||
"narHash": "sha256-5WSng844vXt8uytT5djmqBCkopyle6ciFgteuA9bJpw=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "349de7bc435bdff37785c2466f054ed1766173be",
|
||||
"rev": "705df92694af7093dfbb27109ce16d828a79155f",
|
||||
"type": "github"
|
||||
},
|
||||
"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,
|
||||
MyArgs &args) {
|
||||
|
||||
auto localStore = state.store.dynamic_pointer_cast<nix::LocalFSStore>();
|
||||
auto localStore = state.ctx.store.dynamic_pointer_cast<nix::LocalFSStore>();
|
||||
|
||||
try {
|
||||
// CA derivations do not have static output paths, so we have to
|
||||
// defensively not query output paths in case we encounter one.
|
||||
for (auto &[outputName, optOutputPath] :
|
||||
drvInfo.queryOutputs(!nix::experimentalFeatureSettings.isEnabled(
|
||||
drvInfo.queryOutputs(state, !nix::experimentalFeatureSettings.isEnabled(
|
||||
nix::Xp::CaDerivations))) {
|
||||
if (optOutputPath) {
|
||||
outputs[outputName] =
|
||||
|
@ -63,18 +63,19 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
|
|||
}
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
throw nix::EvalError(state,
|
||||
state.ctx.errors.make<nix::EvalError>(
|
||||
"derivation '%s' does not have valid outputs: %s",
|
||||
attrPath, e.what());
|
||||
attrPath, e.what()
|
||||
).debugThrow();
|
||||
}
|
||||
|
||||
if (args.meta) {
|
||||
nlohmann::json meta_;
|
||||
for (auto &metaName : drvInfo.queryMetaNames()) {
|
||||
for (auto &metaName : drvInfo.queryMetaNames(state)) {
|
||||
nix::NixStringContext context;
|
||||
std::stringstream ss;
|
||||
|
||||
auto metaValue = drvInfo.queryMeta(metaName);
|
||||
auto metaValue = drvInfo.queryMeta(state, metaName);
|
||||
// Skip non-serialisable types
|
||||
// TODO: Fix serialisation of derivations to store paths
|
||||
if (metaValue == 0) {
|
||||
|
@ -96,9 +97,9 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
|
|||
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) {
|
||||
std::set<std::string> inputDrvOutputs;
|
||||
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;
|
||||
}
|
||||
name = drvInfo.queryName();
|
||||
name = drvInfo.queryName(state);
|
||||
system = drv.platform;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,5 +100,5 @@ MyArgs::MyArgs() : MixCommonArgs("nix-eval-jobs") {
|
|||
}
|
||||
|
||||
void MyArgs::parseArgs(char **argv, int argc) {
|
||||
parseCmdline(nix::argvToStrings(argc, argv));
|
||||
parseCmdline(nix::Strings(argv + 1, argv + argc));
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <nlohmann/json_fwd.hpp>
|
||||
#include <lix/libutil/ref.hh>
|
||||
#include <lix/libstore/store-api.hh>
|
||||
#include <map>
|
||||
#include <condition_variable>
|
||||
#include <filesystem>
|
||||
#include <exception>
|
||||
|
@ -47,9 +46,8 @@ using namespace nlohmann;
|
|||
|
||||
static MyArgs myArgs;
|
||||
|
||||
typedef std::function<void(ref<EvalState> state, Bindings &autoArgs,
|
||||
AutoCloseFD &to, AutoCloseFD &from, MyArgs &args)>
|
||||
Processor;
|
||||
using Processor = std::function<void(ref<nix::eval_cache::CachingEvaluator> state, Bindings &autoArgs,
|
||||
AutoCloseFD &to, AutoCloseFD &from, MyArgs &args)>;
|
||||
|
||||
/* Auto-cleanup of fork's process and fds. */
|
||||
struct Proc {
|
||||
|
@ -70,10 +68,10 @@ struct Proc {
|
|||
auto evalStore = myArgs.evalStoreUrl
|
||||
? openStore(*myArgs.evalStoreUrl)
|
||||
: openStore();
|
||||
auto state = std::make_shared<EvalState>(myArgs.searchPath,
|
||||
auto evaluator = nix::make_ref<nix::eval_cache::CachingEvaluator>(myArgs.searchPath,
|
||||
evalStore);
|
||||
Bindings &autoArgs = *myArgs.getAutoArgs(*state);
|
||||
proc(ref<EvalState>(state), autoArgs, *to, *from, myArgs);
|
||||
Bindings &autoArgs = *myArgs.getAutoArgs(*evaluator);
|
||||
proc(evaluator, autoArgs, *to, *from, myArgs);
|
||||
} catch (Error &e) {
|
||||
nlohmann::json err;
|
||||
auto msg = e.msg();
|
||||
|
@ -344,24 +342,16 @@ int main(int argc, char **argv) {
|
|||
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
initGC();
|
||||
initLibExpr();
|
||||
|
||||
myArgs.parseArgs(argv, argc);
|
||||
|
||||
/* FIXME: The build hook in conjunction with import-from-derivation is
|
||||
* causing "unexpected EOF" during eval */
|
||||
settings.builders = "";
|
||||
|
||||
/* Prevent access to paths outside of the Nix search path and
|
||||
to the environment. */
|
||||
evalSettings.restrictEval = false;
|
||||
|
||||
/* When building a flake, use pure evaluation (no access to
|
||||
'getEnv', 'currentSystem' etc. */
|
||||
if (myArgs.impure) {
|
||||
evalSettings.pureEval = false;
|
||||
evalSettings.pureEval.override(false);
|
||||
} else if (myArgs.flake) {
|
||||
evalSettings.pureEval = true;
|
||||
evalSettings.pureEval.override(true);
|
||||
}
|
||||
|
||||
if (myArgs.releaseExpr == "")
|
||||
|
@ -374,7 +364,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (myArgs.showTrace) {
|
||||
loggerSettings.showTrace.assign(true);
|
||||
loggerSettings.showTrace.override(true);
|
||||
}
|
||||
|
||||
Sync<State> state_;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <lix/libutil/canon-path.hh>
|
||||
#include <lix/libcmd/common-eval-args.hh>
|
||||
#include <lix/libutil/error.hh>
|
||||
#include <lix/libexpr/eval-cache.hh>
|
||||
#include <lix/libexpr/eval-inline.hh>
|
||||
#include <lix/libexpr/eval.hh>
|
||||
#include <lix/libexpr/flake/flakeref.hh>
|
||||
|
@ -48,14 +49,14 @@ static nix::Value *releaseExprTopLevelValue(nix::EvalState &state,
|
|||
nix::Value vTop;
|
||||
|
||||
if (args.fromArgs) {
|
||||
nix::Expr &e = state.parseExprFromString(
|
||||
args.releaseExpr, state.rootPath(nix::CanonPath::fromCwd()));
|
||||
nix::Expr &e = state.ctx.parseExprFromString(
|
||||
args.releaseExpr, nix::CanonPath::fromCwd());
|
||||
state.eval(e, vTop);
|
||||
} 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);
|
||||
|
||||
|
@ -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::Value *vRoot = [&]() {
|
||||
auto state = evaluator->begin();
|
||||
if (args.flake) {
|
||||
auto [flakeRef, fragment, outputSpec] =
|
||||
nix::parseFlakeRefWithFragmentAndExtendedOutputsSpec(
|
||||
args.releaseExpr, nix::absPath("."));
|
||||
nix::InstallableFlake flake{
|
||||
{}, state, std::move(flakeRef), fragment, outputSpec,
|
||||
{}, evaluator, std::move(flakeRef), fragment, outputSpec,
|
||||
{}, {}, args.lockFlags};
|
||||
|
||||
return flake.toValue(*state).first;
|
||||
|
@ -92,6 +94,7 @@ void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs,
|
|||
}();
|
||||
|
||||
LineReader fromReader(from.release());
|
||||
auto state = evaluator->begin();
|
||||
|
||||
while (true) {
|
||||
/* 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)
|
||||
.first;
|
||||
|
||||
auto v = state->allocValue();
|
||||
auto v = evaluator->mem.allocValue();
|
||||
state->autoCallFunction(autoArgs, *vTmp, *v);
|
||||
|
||||
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));
|
||||
if (!nix::pathExists(root)) {
|
||||
auto localStore =
|
||||
state->store
|
||||
evaluator->store
|
||||
.dynamic_pointer_cast<nix::LocalFSStore>();
|
||||
auto storePath =
|
||||
localStore->parseStorePath(drv.drvPath);
|
||||
|
@ -151,14 +154,14 @@ void worker(nix::ref<nix::EvalState> state, nix::Bindings &autoArgs,
|
|||
// = true;` for top-level attrset
|
||||
|
||||
for (auto &i :
|
||||
v->attrs->lexicographicOrder(state->symbols)) {
|
||||
const std::string &name = state->symbols[i->name];
|
||||
v->attrs->lexicographicOrder(evaluator->symbols)) {
|
||||
const std::string &name = evaluator->symbols[i->name];
|
||||
attrs.push_back(name);
|
||||
|
||||
if (name == "recurseForDerivations" &&
|
||||
!args.forceRecurse) {
|
||||
auto attrv =
|
||||
v->attrs->get(state->sRecurseForDerivations);
|
||||
v->attrs->get(evaluator->s.recurseForDerivations);
|
||||
recurse = state->forceBool(
|
||||
*attrv->value, attrv->pos,
|
||||
"while evaluating recurseForDerivations");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include <lix/libmain/shared.hh>
|
||||
#include <lix/libexpr/eval.hh>
|
||||
#include <lix/libexpr/eval-cache.hh>
|
||||
|
||||
#include "eval-args.hh"
|
||||
|
||||
|
@ -13,5 +14,5 @@ class EvalState;
|
|||
template <typename T> class ref;
|
||||
} // 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);
|
||||
|
|
Loading…
Reference in a new issue