Merge pull request #9326 from NixOS/unstable-fetchTree-git

Mark `fetchTree` as unstable again
This commit is contained in:
Robert Hensing 2023-11-09 07:44:48 +01:00 committed by GitHub
commit df9bd755a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 5 deletions

View file

@ -17,7 +17,8 @@
- `nix-shell` shebang lines now support single-quoted arguments. - `nix-shell` shebang lines now support single-quoted arguments.
- `builtins.fetchTree` is now marked as stable. - `builtins.fetchTree` is now its own experimental feature, [`fetch-tree`](@docroot@/contributing/experimental-features.md#xp-fetch-tree).
As described in the document for that feature, this is because we anticipate polishing it and then stabilizing it before the rest of Flakes.
- The interface for creating and updating lock files has been overhauled: - The interface for creating and updating lock files has been overhauled:

View file

@ -228,6 +228,7 @@ static RegisterPrimOp primop_fetchTree({
``` ```
)", )",
.fun = prim_fetchTree, .fun = prim_fetchTree,
.experimentalFeature = Xp::FetchTree,
}); });
static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v, static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v,

View file

@ -330,9 +330,11 @@ template<> std::set<ExperimentalFeature> BaseSetting<std::set<ExperimentalFeatur
{ {
std::set<ExperimentalFeature> res; std::set<ExperimentalFeature> res;
for (auto & s : tokenizeString<StringSet>(str)) { for (auto & s : tokenizeString<StringSet>(str)) {
if (auto thisXpFeature = parseExperimentalFeature(s); thisXpFeature) if (auto thisXpFeature = parseExperimentalFeature(s); thisXpFeature) {
res.insert(thisXpFeature.value()); res.insert(thisXpFeature.value());
else if (thisXpFeature.value() == Xp::Flakes)
res.insert(Xp::FetchTree);
} else
warn("unknown experimental feature '%s'", s); warn("unknown experimental feature '%s'", s);
} }
return res; return res;

View file

@ -12,7 +12,19 @@ struct ExperimentalFeatureDetails
std::string_view description; std::string_view description;
}; };
constexpr std::array<ExperimentalFeatureDetails, 16> xpFeatureDetails = {{ /**
* If two different PRs both add an experimental feature, and we just
* used a number for this, we *woudln't* get merge conflict and the
* counter will be incremented once instead of twice, causing a build
* failure.
*
* By instead defining this instead as 1 + the bottom experimental
* feature, we either have no issue at all if few features are not added
* at the end of the list, or a proper merge conflict if they are.
*/
constexpr size_t numXpFeatures = 1 + static_cast<size_t>(Xp::VerifiedFetches);
constexpr std::array<ExperimentalFeatureDetails, numXpFeatures> xpFeatureDetails = {{
{ {
.tag = Xp::CaDerivations, .tag = Xp::CaDerivations,
.name = "ca-derivations", .name = "ca-derivations",
@ -62,6 +74,20 @@ constexpr std::array<ExperimentalFeatureDetails, 16> xpFeatureDetails = {{
flake`](@docroot@/command-ref/new-cli/nix3-flake.md) for details. flake`](@docroot@/command-ref/new-cli/nix3-flake.md) for details.
)", )",
}, },
{
.tag = Xp::FetchTree,
.name = "fetch-tree",
.description = R"(
Enable the use of the [`fetchTree`](@docroot@/language/builtins.md#builtins-fetchTree) built-in function in the Nix language.
`fetchTree` exposes a large suite of fetching functionality in a more systematic way.
The [`flakes`](#xp-feature-flakes) feature flag always enables `fetch-tree`.
This built-in was previously guarded by the `flakes` experimental feature because of that overlap,
but since the plan is to work on stabilizing this first (due 2024 Q1), we are putting it underneath a separate feature.
Once we've made the changes we want to make, enabling just this feature will serve as a "release candidate" --- allowing users to try out the functionality we want to stabilize and not any other functionality we don't yet want to, in isolation.
)",
},
{ {
.tag = Xp::NixCommand, .tag = Xp::NixCommand,
.name = "nix-command", .name = "nix-command",

View file

@ -20,6 +20,7 @@ enum struct ExperimentalFeature
CaDerivations, CaDerivations,
ImpureDerivations, ImpureDerivations,
Flakes, Flakes,
FetchTree,
NixCommand, NixCommand,
RecursiveNix, RecursiveNix,
NoUrlLiterals, NoUrlLiterals,

View file

@ -50,7 +50,8 @@ exp_cores=$(nix show-config | grep '^cores' | cut -d '=' -f 2 | xargs)
exp_features=$(nix show-config | grep '^experimental-features' | cut -d '=' -f 2 | xargs) exp_features=$(nix show-config | grep '^experimental-features' | cut -d '=' -f 2 | xargs)
[[ $prev != $exp_cores ]] [[ $prev != $exp_cores ]]
[[ $exp_cores == "4242" ]] [[ $exp_cores == "4242" ]]
[[ $exp_features == "flakes nix-command" ]] # flakes implies fetch-tree
[[ $exp_features == "fetch-tree flakes nix-command" ]]
# Test that it's possible to retrieve a single setting's value # Test that it's possible to retrieve a single setting's value
val=$(nix show-config | grep '^warn-dirty' | cut -d '=' -f 2 | xargs) val=$(nix show-config | grep '^warn-dirty' | cut -d '=' -f 2 | xargs)