Compare commits

..

1 commit

Author SHA1 Message Date
c39b8027dc
flake.lock: Update
Flake lock file updates:

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/3d04084d54bedc3d6b8b736c70ef449225c361b1' (2024-10-01)
  → 'github:hercules-ci/flake-parts/506278e768c2a08bec68eb62932193e341f55c90' (2024-11-01)
• Updated input 'lix':
    '2734a9cf94.tar.gz?narHash=sha256-XME7TzBvjK6GEmZqPLK%2B2%2BWk0qnwc7DCwYH434hMcOM%3D&rev=2734a9cf94debc6baef4e7d4d9fa28cc28f5b31d' (2024-10-23)
  → 'c859d03013.tar.gz?narHash=sha256-bq21I1EjXJa/s5Rra9J9ot2NkPCnI0F5uNPurwYLdpE%3D&rev=c859d03013712b349d82ee6223948d6d03e63a8d' (2024-11-15)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/45e5197248e59e92e88956c5aa12553a7f62337f' (2024-10-25)
  → 'github:NixOS/nixpkgs/035d434d48f4375ac5d3a620954cf5fda7dd7c36' (2024-11-15)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/aac86347fb5063960eccb19493e0cadcdb4205ca' (2024-10-22)
  → 'github:numtide/treefmt-nix/746901bb8dba96d154b66492a29f5db0693dbfcc' (2024-10-30)
2024-11-16 22:15:02 +01:00
6 changed files with 42 additions and 45 deletions

View file

@ -47,11 +47,11 @@
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1733448312,
"narHash": "sha256-id5U81bzXk/Lg900nGLM4CQb0wmTdzIvQz7CZk2OcTM=",
"rev": "2a9e560570982a91937d199af3e7b7a8f3cbe14b",
"lastModified": 1731683711,
"narHash": "sha256-bq21I1EjXJa/s5Rra9J9ot2NkPCnI0F5uNPurwYLdpE=",
"rev": "c859d03013712b349d82ee6223948d6d03e63a8d",
"type": "tarball",
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2a9e560570982a91937d199af3e7b7a8f3cbe14b.tar.gz?rev=2a9e560570982a91937d199af3e7b7a8f3cbe14b"
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/c859d03013712b349d82ee6223948d6d03e63a8d.tar.gz?rev=c859d03013712b349d82ee6223948d6d03e63a8d"
},
"original": {
"type": "tarball",
@ -65,11 +65,11 @@
]
},
"locked": {
"lastModified": 1731952509,
"narHash": "sha256-p4gB3Rhw8R6Ak4eMl8pqjCPOLCZRqaehZxdZ/mbFClM=",
"lastModified": 1729742964,
"narHash": "sha256-B4mzTcQ0FZHdpeWcpDYPERtyjJd/NIuaQ9+BV1h+MpA=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "7b5f051df789b6b20d259924d349a9ba3319b226",
"rev": "e04df33f62cdcf93d73e9a04142464753a16db67",
"type": "github"
},
"original": {
@ -96,11 +96,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1733408989,
"narHash": "sha256-VCQpCQy+6ik+oYKWUCvq0WM2V7UtEKldqdsEzCNEOLc=",
"lastModified": 1731663789,
"narHash": "sha256-x07g4NcqGP6mQn6AISXJaks9sQYDjZmTMBlKIvajvyc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d916387b68a74040a3873ad2a08a559c60cedb5e",
"rev": "035d434d48f4375ac5d3a620954cf5fda7dd7c36",
"type": "github"
},
"original": {
@ -158,11 +158,11 @@
]
},
"locked": {
"lastModified": 1732292307,
"narHash": "sha256-5WSng844vXt8uytT5djmqBCkopyle6ciFgteuA9bJpw=",
"lastModified": 1730321837,
"narHash": "sha256-vK+a09qq19QNu2MlLcvN4qcRctJbqWkX7ahgPZ/+maI=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "705df92694af7093dfbb27109ce16d828a79155f",
"rev": "746901bb8dba96d154b66492a29f5db0693dbfcc",
"type": "github"
},
"original": {

View file

@ -45,13 +45,13 @@ queryIsCached(nix::Store &store,
Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
MyArgs &args) {
auto localStore = state.ctx.store.dynamic_pointer_cast<nix::LocalFSStore>();
auto localStore = state.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(state, !nix::experimentalFeatureSettings.isEnabled(
drvInfo.queryOutputs(!nix::experimentalFeatureSettings.isEnabled(
nix::Xp::CaDerivations))) {
if (optOutputPath) {
outputs[outputName] =
@ -63,19 +63,18 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
}
}
} catch (const std::exception &e) {
state.ctx.errors.make<nix::EvalError>(
throw nix::EvalError(state,
"derivation '%s' does not have valid outputs: %s",
attrPath, e.what()
).debugThrow();
attrPath, e.what());
}
if (args.meta) {
nlohmann::json meta_;
for (auto &metaName : drvInfo.queryMetaNames(state)) {
for (auto &metaName : drvInfo.queryMetaNames()) {
nix::NixStringContext context;
std::stringstream ss;
auto metaValue = drvInfo.queryMeta(state, metaName);
auto metaValue = drvInfo.queryMeta(metaName);
// Skip non-serialisable types
// TODO: Fix serialisation of derivations to store paths
if (metaValue == 0) {
@ -97,9 +96,9 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
cacheStatus = Drv::CacheStatus::Unknown;
}
drvPath = localStore->printStorePath(drvInfo.requireDrvPath(state));
drvPath = localStore->printStorePath(drvInfo.requireDrvPath());
auto drv = localStore->readDerivation(drvInfo.requireDrvPath(state));
auto drv = localStore->readDerivation(drvInfo.requireDrvPath());
for (const auto &[inputDrvPath, inputNode] : drv.inputDrvs.map) {
std::set<std::string> inputDrvOutputs;
for (auto &outputName : inputNode.value) {
@ -107,7 +106,7 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
}
inputDrvs[localStore->printStorePath(inputDrvPath)] = inputDrvOutputs;
}
name = drvInfo.queryName(state);
name = drvInfo.queryName();
system = drv.platform;
}

View file

@ -100,5 +100,5 @@ MyArgs::MyArgs() : MixCommonArgs("nix-eval-jobs") {
}
void MyArgs::parseArgs(char **argv, int argc) {
parseCmdline(nix::Strings(argv + 1, argv + argc));
parseCmdline(nix::argvToStrings(argc, argv));
}

View file

@ -24,6 +24,7 @@
#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>
@ -46,8 +47,9 @@ using namespace nlohmann;
static MyArgs myArgs;
using Processor = std::function<void(ref<nix::eval_cache::CachingEvaluator> state, Bindings &autoArgs,
AutoCloseFD &to, AutoCloseFD &from, MyArgs &args)>;
typedef std::function<void(ref<EvalState> state, Bindings &autoArgs,
AutoCloseFD &to, AutoCloseFD &from, MyArgs &args)>
Processor;
/* Auto-cleanup of fork's process and fds. */
struct Proc {
@ -68,10 +70,10 @@ struct Proc {
auto evalStore = myArgs.evalStoreUrl
? openStore(*myArgs.evalStoreUrl)
: openStore();
auto evaluator = nix::make_ref<nix::eval_cache::CachingEvaluator>(myArgs.searchPath,
auto state = std::make_shared<EvalState>(myArgs.searchPath,
evalStore);
Bindings &autoArgs = *myArgs.getAutoArgs(*evaluator);
proc(evaluator, autoArgs, *to, *from, myArgs);
Bindings &autoArgs = *myArgs.getAutoArgs(*state);
proc(ref<EvalState>(state), autoArgs, *to, *from, myArgs);
} catch (Error &e) {
nlohmann::json err;
auto msg = e.msg();

View file

@ -14,7 +14,6 @@
#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>
@ -49,14 +48,14 @@ static nix::Value *releaseExprTopLevelValue(nix::EvalState &state,
nix::Value vTop;
if (args.fromArgs) {
nix::Expr &e = state.ctx.parseExprFromString(
args.releaseExpr, nix::CanonPath::fromCwd());
nix::Expr &e = state.parseExprFromString(
args.releaseExpr, state.rootPath(nix::CanonPath::fromCwd()));
state.eval(e, vTop);
} else {
state.evalFile(nix::lookupFileArg(state.ctx, args.releaseExpr), vTop);
state.evalFile(lookupFileArg(state, args.releaseExpr), vTop);
}
auto vRoot = state.ctx.mem.allocValue();
auto vRoot = state.allocValue();
state.autoCallFunction(autoArgs, vTop, *vRoot);
@ -74,17 +73,16 @@ static std::string attrPathJoin(nlohmann::json input) {
});
}
void worker(nix::ref<nix::eval_cache::CachingEvaluator> evaluator, nix::Bindings &autoArgs,
void worker(nix::ref<nix::EvalState> state, 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{
{}, evaluator, std::move(flakeRef), fragment, outputSpec,
{}, state, std::move(flakeRef), fragment, outputSpec,
{}, {}, args.lockFlags};
return flake.toValue(*state).first;
@ -94,7 +92,6 @@ void worker(nix::ref<nix::eval_cache::CachingEvaluator> evaluator, nix::Bindings
}();
LineReader fromReader(from.release());
auto state = evaluator->begin();
while (true) {
/* Wait for the collector to send us a job name. */
@ -122,7 +119,7 @@ void worker(nix::ref<nix::eval_cache::CachingEvaluator> evaluator, nix::Bindings
nix::findAlongAttrPath(*state, attrPathS, autoArgs, *vRoot)
.first;
auto v = evaluator->mem.allocValue();
auto v = state->allocValue();
state->autoCallFunction(autoArgs, *vTmp, *v);
if (v->type() == nix::nAttrs) {
@ -139,7 +136,7 @@ void worker(nix::ref<nix::eval_cache::CachingEvaluator> evaluator, nix::Bindings
std::string(nix::baseNameOf(drv.drvPath));
if (!nix::pathExists(root)) {
auto localStore =
evaluator->store
state->store
.dynamic_pointer_cast<nix::LocalFSStore>();
auto storePath =
localStore->parseStorePath(drv.drvPath);
@ -154,14 +151,14 @@ void worker(nix::ref<nix::eval_cache::CachingEvaluator> evaluator, nix::Bindings
// = true;` for top-level attrset
for (auto &i :
v->attrs->lexicographicOrder(evaluator->symbols)) {
const std::string &name = evaluator->symbols[i->name];
v->attrs->lexicographicOrder(state->symbols)) {
const std::string &name = state->symbols[i->name];
attrs.push_back(name);
if (name == "recurseForDerivations" &&
!args.forceRecurse) {
auto attrv =
v->attrs->get(evaluator->s.recurseForDerivations);
v->attrs->get(state->sRecurseForDerivations);
recurse = state->forceBool(
*attrv->value, attrv->pos,
"while evaluating recurseForDerivations");

View file

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