diff --git a/lix/legacy/user-env.cc b/lix/legacy/user-env.cc index 16eb57a75..3eb0fcc95 100644 --- a/lix/legacy/user-env.cc +++ b/lix/legacy/user-env.cc @@ -111,7 +111,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, /* Construct a Nix expression that calls the user environment builder with the manifest as argument. */ auto attrs = state.ctx.buildBindings(3); - state.ctx.paths.mkStorePathString(manifestFile, attrs.alloc("manifest")); + attrs.alloc("manifest") = state.ctx.paths.mkStorePathString(manifestFile); attrs.insert(state.ctx.symbols.create("derivations"), vManifest); Value args = {NewValueAs::attrs, attrs}; diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index 05248325f..befaabf4e 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -438,7 +438,7 @@ void EvalPaths::allowAndSetStorePathString(const StorePath & storePath, Value & { allowPath(storePath); - mkStorePathString(storePath, v); + v = mkStorePathString(storePath); } CheckedSourcePath EvalPaths::checkSourcePath(const SourcePath & path_) @@ -865,10 +865,9 @@ void EvalState::mkPos(Value & v, PosIdx p) v.mkNull(); } - -void EvalPaths::mkStorePathString(const StorePath & p, Value & v) +Value EvalPaths::mkStorePathString(const StorePath & p) { - v = { + return { NewValueAs::string, store->printStorePath(p), NixStringContext{ diff --git a/lix/libexpr/eval.hh b/lix/libexpr/eval.hh index 656154d2f..40a4817df 100644 --- a/lix/libexpr/eval.hh +++ b/lix/libexpr/eval.hh @@ -449,7 +449,7 @@ public: * The string is the printed store path with a context containing a * single `NixStringContextElem::Opaque` element of that store path. */ - void mkStorePathString(const StorePath & storePath, Value & v); + Value mkStorePathString(const StorePath & storePath); }; struct EvalStatistics diff --git a/lix/libexpr/primops/fetchMercurial.cc b/lix/libexpr/primops/fetchMercurial.cc index 8807e1406..a07a360ff 100644 --- a/lix/libexpr/primops/fetchMercurial.cc +++ b/lix/libexpr/primops/fetchMercurial.cc @@ -88,7 +88,7 @@ void prim_fetchMercurial(EvalState & state, Value ** args, Value & v) auto [tree, input2] = state.aio.blockOn(input.fetch(state.ctx.store)); auto attrs2 = state.ctx.buildBindings(8); - state.ctx.paths.mkStorePathString(tree.storePath, attrs2.alloc(state.ctx.symbols.sym_outPath)); + attrs2.alloc(state.ctx.symbols.sym_outPath) = state.ctx.paths.mkStorePathString(tree.storePath); if (input2.getRef()) attrs2.alloc("branch") = {NewValueAs::string, *input2.getRef()}; // Backward compatibility: set 'rev' to diff --git a/lix/libexpr/primops/fetchTree.cc b/lix/libexpr/primops/fetchTree.cc index f0f90cd12..0b6b9793f 100644 --- a/lix/libexpr/primops/fetchTree.cc +++ b/lix/libexpr/primops/fetchTree.cc @@ -26,7 +26,7 @@ Value emitTreeAttrs( auto attrs = state.buildBindings(10); - state.paths.mkStorePathString(tree.storePath, attrs.alloc(state.symbols.sym_outPath)); + attrs.alloc(state.symbols.sym_outPath) = state.paths.mkStorePathString(tree.storePath); // FIXME: support arbitrary input attributes. diff --git a/tests/unit/libexpr/derived-path.cc b/tests/unit/libexpr/derived-path.cc index bb9611dbd..653e7d74c 100644 --- a/tests/unit/libexpr/derived-path.cc +++ b/tests/unit/libexpr/derived-path.cc @@ -27,8 +27,7 @@ RC_GTEST_FIXTURE_PROP( prop_opaque_path_round_trip, (const SingleDerivedPath::Opaque & o)) { - Value v; - evaluator.paths.mkStorePathString(o.path, v); + Value v = evaluator.paths.mkStorePathString(o.path); auto d = state.coerceToSingleDerivedPath(noPos, v, ""); RC_ASSERT(SingleDerivedPath { o } == d); }