From 3a0b1047ff897c7a9066aab8b1e2d04bf6ba72bb Mon Sep 17 00:00:00 2001 From: Gavin John Date: Sun, 5 Jan 2025 10:29:09 -0500 Subject: [PATCH 1/3] libutil/experimental-features: Add pure-storepath-builtin experimental feature --- src/libutil/experimental-features.cc | 13 +++++++++++++ src/libutil/experimental-features.hh | 1 + 2 files changed, 14 insertions(+) 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, From 591ad72f474d8d197cdb8284f005671bc151372c Mon Sep 17 00:00:00 2001 From: Gavin John Date: Sun, 5 Jan 2025 10:42:57 -0500 Subject: [PATCH 2/3] libexpr/primops: allow storePath in pure eval if pure-storepath-builtin feature is enabled --- src/libexpr/primops.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 7d6fdb91053184072300ae7aea04e5b20e2658c6 Mon Sep 17 00:00:00 2001 From: Gavin John Date: Sun, 5 Jan 2025 10:58:26 -0500 Subject: [PATCH 3/3] rl-next: add pure-storepath-builtin release entry --- doc/manual/rl-next/pure-storepath-builtin.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 doc/manual/rl-next/pure-storepath-builtin.md 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.