diff --git a/doc/manual/rl-next/stabilize-fetchtree.md b/doc/manual/rl-next/stabilize-fetchtree.md new file mode 100644 index 00000000000..f9bef1bd0e7 --- /dev/null +++ b/doc/manual/rl-next/stabilize-fetchtree.md @@ -0,0 +1,9 @@ +--- +synopsis: Stabilize fetchTree +prs: 10068 +--- + +The core of `fetchTree` is now stable. +This includes +- the `fetchTree` function itself +- all the existing fetchers, except `git` (still unstable because of some reproducibility concerns) diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc index 1997d55137c..f246a431a49 100644 --- a/src/libexpr/primops/fetchTree.cc +++ b/src/libexpr/primops/fetchTree.cc @@ -159,9 +159,9 @@ static void fetchTree( } input = fetchers::Input::fromAttrs(std::move(attrs)); } else { - if (!experimentalFeatureSettings.isEnabled(Xp::Flakes)) + if (!experimentalFeatureSettings.isEnabled(Xp::FetchTreeUrls)) state.error( - "passing a string argument to 'fetchTree' requires the 'flakes' experimental feature" + "passing a string argument to 'fetchTree' requires the 'fetch-tree-urls' experimental feature" ).atPos(pos).debugThrow(); input = fetchers::Input::fromURL(url); } @@ -410,7 +410,6 @@ static RegisterPrimOp primop_fetchTree({ > ``` )", .fun = prim_fetchTree, - .experimentalFeature = Xp::FetchTree, }); static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v, diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index bef945d5414..2148e4efe65 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -282,6 +282,11 @@ struct GitInputScheme : InputScheme return res; } + std::optional experimentalFeature() const override + { + return Xp::FetchTreeGit; + } + void clone(const Input & input, const Path & destDir) const override { auto repoInfo = getRepoInfo(input); diff --git a/src/libutil/config.cc b/src/libutil/config.cc index 37f5b50c7b3..27d1af4d8f2 100644 --- a/src/libutil/config.cc +++ b/src/libutil/config.cc @@ -334,8 +334,14 @@ template<> std::set BaseSetting(str)) { if (auto thisXpFeature = parseExperimentalFeature(s); thisXpFeature) { res.insert(thisXpFeature.value()); - if (thisXpFeature.value() == Xp::Flakes) + if (thisXpFeature.value() == Xp::Flakes) { res.insert(Xp::FetchTree); + res.insert(Xp::FetchTreeGit); + res.insert(Xp::FetchTreeUrls); + } else if (thisXpFeature.value() == Xp::FetchTree) { + res.insert(Xp::FetchTreeGit); + res.insert(Xp::FetchTreeUrls); + } } else warn("unknown experimental feature '%s'", s); } diff --git a/src/libutil/experimental-features.cc b/src/libutil/experimental-features.cc index 9b46fc5b00a..1c11a7646fd 100644 --- a/src/libutil/experimental-features.cc +++ b/src/libutil/experimental-features.cc @@ -78,13 +78,23 @@ constexpr std::array xpFeatureDetails .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 generic interface for fetching remote file system trees from different types of remote sources. - 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. - - Enabling just this feature serves as a "release candidate", allowing users to try it out in isolation. + Backwards-compatibility alias for + [fetch-tree-git](#xp-feature-fetch-tree-git) and + [fetch-tree-urls](#xp-feature-fetch-tree-urls). + )", + }, + { + .tag = Xp::FetchTreeGit, + .name = "fetch-tree-git", + .description = R"( + Enable the use of the `git` [`fetchTree`](@docroot@/language/builtins.md#builtins-fetchTree) fetcher. + )", + }, + { + .tag = Xp::FetchTreeUrls, + .name = "fetch-tree-urls", + .description = R"( + Enable the use of the [URL-like syntax](@docroot@/command-ref/new-cli/nix3-flake.html#url-like-syntax) in [`fetchTree`](@docroot@/language/builtins.md#builtins-fetchTree). )", }, { diff --git a/src/libutil/experimental-features.hh b/src/libutil/experimental-features.hh index eae4fa9b856..85736775873 100644 --- a/src/libutil/experimental-features.hh +++ b/src/libutil/experimental-features.hh @@ -21,6 +21,8 @@ enum struct ExperimentalFeature ImpureDerivations, Flakes, FetchTree, + FetchTreeGit, + FetchTreeUrls, NixCommand, GitHashing, RecursiveNix, diff --git a/tests/functional/common/vars-and-functions.sh.in b/tests/functional/common/vars-and-functions.sh.in index 8fef29f97a7..791f032494b 100644 --- a/tests/functional/common/vars-and-functions.sh.in +++ b/tests/functional/common/vars-and-functions.sh.in @@ -232,6 +232,12 @@ enableFeatures() { sed -i 's/experimental-features .*/& '"$features"'/' "$NIX_CONF_DIR"/nix.conf } +disableFeature() { + local feature="$1" + sed -i '/^\(extra-\)\?experimental-features/s/\b'"$feature"'\b//g' "$NIX_CONF_DIR"/nix.conf + sed -i '/^\(extra-\)\?experimental-features/s/\b'"$feature"'\b//g' "$NIX_CONF_DIR"/nix.conf.extra +} + set -x onError() { diff --git a/tests/functional/config.sh b/tests/functional/config.sh index 324fe95bd71..66d04335afd 100644 --- a/tests/functional/config.sh +++ b/tests/functional/config.sh @@ -50,8 +50,13 @@ exp_cores=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs) exp_features=$(nix config show | grep '^experimental-features' | cut -d '=' -f 2 | xargs) [[ $prev != $exp_cores ]] [[ $exp_cores == "4242" ]] -# flakes implies fetch-tree -[[ $exp_features == "fetch-tree flakes nix-command" ]] +# flakes implies fetch-tree and a bunch of other things +[[ $exp_features == "fetch-tree fetch-tree-git fetch-tree-urls flakes nix-command" ]] +[[ + $(NIX_CONFIG="experimental-features = fetch-tree nix-command" nix config show | grep '^experimental-features' | cut -d '=' -f 2 | xargs) \ + == \ + "fetch-tree fetch-tree-git fetch-tree-urls nix-command" +]] # Test that it's possible to retrieve a single setting's value val=$(nix config show | grep '^warn-dirty' | cut -d '=' -f 2 | xargs) diff --git a/tests/functional/fetchTree-file.sh b/tests/functional/fetchTree-file.sh index 6395c133d8a..5ac63236537 100644 --- a/tests/functional/fetchTree-file.sh +++ b/tests/functional/fetchTree-file.sh @@ -2,6 +2,8 @@ source common.sh clearStore +disableFeature "flakes" + cd "$TEST_ROOT" test_fetch_file () { @@ -21,6 +23,7 @@ EOF # Make sure that `http(s)` and `file` flake inputs are properly extracted when # they should be, and treated as opaque files when they should be test_file_flake_input () { + enableFeatures "flakes" rm -fr "$TEST_ROOT/testFlake"; mkdir "$TEST_ROOT/testFlake"; pushd testFlake