diff --git a/doc/manual/rl-next/pure-storepath-builtin.md b/doc/manual/rl-next/pure-storepath-builtin.md new file mode 100644 index 00000000000..8526d7e5949 --- /dev/null +++ b/doc/manual/rl-next/pure-storepath-builtin.md @@ -0,0 +1,10 @@ +--- +synopsis: "Add pure-storepath-builtin experimental feature" +issues: [ 5868 ] +prs: [ 12141 ] +--- + +The `pure-storepath-builtin` [experimental feature](@docroot@/language/builtins.md) was added, which controls whether [`storePath`](@docroot@/language/builtins.md#builtins-storePath) should be allowed in pure evaluation mode. If the `pure-storepath-builtin` +experimental feature is enabled, `storePath` will no longer error when run in pure evaluation mode. + +This is intended as a stop-gap solution while the correct behaviour of `storePath` is debated in the linked issue. diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index a0e2753b5ec..450da424e13 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1628,7 +1628,7 @@ static RegisterPrimOp primop_toPath({ corner cases. */ static void prim_storePath(EvalState & state, const PosIdx pos, Value * * args, Value & v) { - if (state.settings.pureEval) + if (state.settings.pureEval && !experimentalFeatureSettings.isEnabled(Xp::PureStorePathBuiltin)) state.error( "'%s' is not allowed in pure evaluation mode", "builtins.storePath" diff --git a/src/libutil/experimental-features.cc b/src/libutil/experimental-features.cc index a0c955816e9..fb7217624b3 100644 --- a/src/libutil/experimental-features.cc +++ b/src/libutil/experimental-features.cc @@ -246,6 +246,19 @@ constexpr std::array xpFeatureDetails )", .trackingUrl = "https://github.com/NixOS/nix/milestone/39", }, + { + .tag = Xp::PureStorePathBuiltin, + .name = "pure-storepath-builtin", + .description = R"( + Allow the use of [`storePath`](@docroot@/language/builtins.md#builtins-storePath) + in pure evaluation mode. No consensus has been found as to whether `storePath` + should be considered pure or impure, see the following issue: + + https://github.com/NixOS/nix/issues/5868 + )", + // NOTE: This is not a milestone, since "tracking" this experimental feature really consists of discussing whether storePath should be pure or not. + .trackingUrl = "https://github.com/NixOS/nix/issues/5868", + }, { .tag = Xp::ParseTomlTimestamps, .name = "parse-toml-timestamps", diff --git a/src/libutil/experimental-features.hh b/src/libutil/experimental-features.hh index 412bf08864d..65eaf27a2cf 100644 --- a/src/libutil/experimental-features.hh +++ b/src/libutil/experimental-features.hh @@ -30,6 +30,7 @@ enum struct ExperimentalFeature Cgroups, DaemonTrustOverride, DynamicDerivations, + PureStorePathBuiltin, ParseTomlTimestamps, ReadOnlyLocalStore, LocalOverlayStore,