Compare commits

...

5 Commits

Author SHA1 Message Date
Théophane Hufschmitt
fd5e9d2778 Test the fetchtree implied experimental features
Make sure that enabling `fetch-tree` also enables `fetch-tree-git` and
`fetch-tree-urls`.
2024-02-23 15:51:01 +01:00
Théophane Hufschmitt
2d72715aa3 Add a release note for the fetchTree stabilisation 2024-02-23 15:14:21 +01:00
Théophane Hufschmitt
9553fc5a53 Test the non-experimental fetchtree
Run the fetchTree-file test without the experimental feature to make
sure that it works properly
2024-02-23 15:04:54 +01:00
Théophane Hufschmitt
f0fd3f7c0a Break down the fetch-tree experimental-feature
Add two new features:
- `fetch-tree-git` to enable the `git` fetcher for `fetchTree`
- `fetch-tree-urls` to enable the URL-like syntax for `fetchTree`

`fetch-tree` is kept as a backwards-compatibility alias for the two new
features.
2024-02-22 14:40:23 +01:00
Théophane Hufschmitt
a6c36e8c40 Remove the FetchTree experimental feature 2024-02-19 15:57:08 +01:00
9 changed files with 58 additions and 13 deletions

View File

@@ -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)

View File

@@ -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<EvalError>(
"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,

View File

@@ -282,6 +282,11 @@ struct GitInputScheme : InputScheme
return res;
}
std::optional<ExperimentalFeature> experimentalFeature() const override
{
return Xp::FetchTreeGit;
}
void clone(const Input & input, const Path & destDir) const override
{
auto repoInfo = getRepoInfo(input);

View File

@@ -334,8 +334,14 @@ template<> std::set<ExperimentalFeature> BaseSetting<std::set<ExperimentalFeatur
for (auto & s : tokenizeString<StringSet>(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);
}

View File

@@ -78,13 +78,23 @@ constexpr std::array<ExperimentalFeatureDetails, numXpFeatures> 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).
)",
},
{

View File

@@ -21,6 +21,8 @@ enum struct ExperimentalFeature
ImpureDerivations,
Flakes,
FetchTree,
FetchTreeGit,
FetchTreeUrls,
NixCommand,
GitHashing,
RecursiveNix,

View File

@@ -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() {

View File

@@ -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)

View File

@@ -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