diff --git a/src/libexpr-tests/derived-path.cc b/src/libexpr-tests/derived-path.cc index d5fc6f201..634f9bf69 100644 --- a/src/libexpr-tests/derived-path.cc +++ b/src/libexpr-tests/derived-path.cc @@ -44,11 +44,11 @@ RC_GTEST_FIXTURE_PROP( * to worry about race conditions if the tests run concurrently. */ ExperimentalFeatureSettings mockXpSettings; - mockXpSettings.set("experimental-features", "ca-derivations"); + mockXpSettings.set("experimental-features", "ca-derivations dynamic-derivations"); auto * v = state.allocValue(); state.mkOutputString(*v, b, std::nullopt, mockXpSettings); - auto [d, _] = state.coerceToSingleDerivedPathUnchecked(noPos, *v, ""); + auto [d, _] = state.coerceToSingleDerivedPathUnchecked(noPos, *v, "", mockXpSettings); RC_ASSERT(SingleDerivedPath { b } == d); } @@ -57,9 +57,12 @@ RC_GTEST_FIXTURE_PROP( prop_derived_path_built_out_path_round_trip, (const SingleDerivedPath::Built & b, const StorePath & outPath)) { + ExperimentalFeatureSettings mockXpSettings; + mockXpSettings.set("experimental-features", "dynamic-derivations"); + auto * v = state.allocValue(); - state.mkOutputString(*v, b, outPath); - auto [d, _] = state.coerceToSingleDerivedPathUnchecked(noPos, *v, ""); + state.mkOutputString(*v, b, outPath, mockXpSettings); + auto [d, _] = state.coerceToSingleDerivedPathUnchecked(noPos, *v, "", mockXpSettings); RC_ASSERT(SingleDerivedPath { b } == d); } diff --git a/src/libexpr-tests/value/context.cc b/src/libexpr-tests/value/context.cc index 761286dbd..c8d62772f 100644 --- a/src/libexpr-tests/value/context.cc +++ b/src/libexpr-tests/value/context.cc @@ -124,7 +124,9 @@ RC_GTEST_PROP( prop_round_rip, (const NixStringContextElem & o)) { - RC_ASSERT(o == NixStringContextElem::parse(o.to_string())); + ExperimentalFeatureSettings xpSettings; + xpSettings.set("experimental-features", "dynamic-derivations"); + RC_ASSERT(o == NixStringContextElem::parse(o.to_string(), xpSettings)); } #endif diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index b9b89773f..2dcee49d9 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -2245,18 +2245,18 @@ std::string_view EvalState::forceString(Value & v, const PosIdx pos, std::string } -void copyContext(const Value & v, NixStringContext & context) +void copyContext(const Value & v, NixStringContext & context, const ExperimentalFeatureSettings & xpSettings) { if (v.payload.string.context) for (const char * * p = v.payload.string.context; *p; ++p) - context.insert(NixStringContextElem::parse(*p)); + context.insert(NixStringContextElem::parse(*p, xpSettings)); } -std::string_view EvalState::forceString(Value & v, NixStringContext & context, const PosIdx pos, std::string_view errorCtx) +std::string_view EvalState::forceString(Value & v, NixStringContext & context, const PosIdx pos, std::string_view errorCtx, const ExperimentalFeatureSettings & xpSettings) { auto s = forceString(v, pos, errorCtx); - copyContext(v, context); + copyContext(v, context, xpSettings); return s; } @@ -2462,10 +2462,10 @@ StorePath EvalState::coerceToStorePath(const PosIdx pos, Value & v, NixStringCon } -std::pair EvalState::coerceToSingleDerivedPathUnchecked(const PosIdx pos, Value & v, std::string_view errorCtx) +std::pair EvalState::coerceToSingleDerivedPathUnchecked(const PosIdx pos, Value & v, std::string_view errorCtx, const ExperimentalFeatureSettings & xpSettings) { NixStringContext context; - auto s = forceString(v, context, pos, errorCtx); + auto s = forceString(v, context, pos, errorCtx, xpSettings); auto csize = context.size(); if (csize != 1) error( diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 5e3e915c6..8bb8bbd32 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -159,7 +159,7 @@ void printEnvBindings(const SymbolTable & st, const StaticEnv & se, const Env & std::unique_ptr mapStaticEnvBindings(const SymbolTable & st, const StaticEnv & se, const Env & env); -void copyContext(const Value & v, NixStringContext & context); +void copyContext(const Value & v, NixStringContext & context, const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings); std::string printValue(EvalState & state, Value & v); @@ -525,7 +525,7 @@ public: */ void forceFunction(Value & v, const PosIdx pos, std::string_view errorCtx); std::string_view forceString(Value & v, const PosIdx pos, std::string_view errorCtx); - std::string_view forceString(Value & v, NixStringContext & context, const PosIdx pos, std::string_view errorCtx); + std::string_view forceString(Value & v, NixStringContext & context, const PosIdx pos, std::string_view errorCtx, const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings); std::string_view forceStringNoCtx(Value & v, const PosIdx pos, std::string_view errorCtx); template @@ -577,7 +577,7 @@ public: /** * Part of `coerceToSingleDerivedPath()` without any store IO which is exposed for unit testing only. */ - std::pair coerceToSingleDerivedPathUnchecked(const PosIdx pos, Value & v, std::string_view errorCtx); + std::pair coerceToSingleDerivedPathUnchecked(const PosIdx pos, Value & v, std::string_view errorCtx, const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings); /** * Coerce to `SingleDerivedPath`. diff --git a/src/libstore-tests/derived-path.cc b/src/libstore-tests/derived-path.cc index c62d79a78..64e3a12c9 100644 --- a/src/libstore-tests/derived-path.cc +++ b/src/libstore-tests/derived-path.cc @@ -84,7 +84,9 @@ RC_GTEST_FIXTURE_PROP( prop_legacy_round_rip, (const DerivedPath & o)) { - RC_ASSERT(o == DerivedPath::parseLegacy(*store, o.to_string_legacy(*store))); + ExperimentalFeatureSettings xpSettings; + xpSettings.set("experimental-features", "dynamic-derivations"); + RC_ASSERT(o == DerivedPath::parseLegacy(*store, o.to_string_legacy(*store), xpSettings)); } RC_GTEST_FIXTURE_PROP( @@ -92,7 +94,9 @@ RC_GTEST_FIXTURE_PROP( prop_round_rip, (const DerivedPath & o)) { - RC_ASSERT(o == DerivedPath::parse(*store, o.to_string(*store))); + ExperimentalFeatureSettings xpSettings; + xpSettings.set("experimental-features", "dynamic-derivations"); + RC_ASSERT(o == DerivedPath::parse(*store, o.to_string(*store), xpSettings)); } #endif