mirror of
https://github.com/NixOS/nix
synced 2025-06-28 22:01:15 +02:00
Merge pull request #29 from DeterminateSystems/stable-flakes
Make the flakes experimental feature stable
This commit is contained in:
commit
51583851a2
28 changed files with 67 additions and 121 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -23,7 +23,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
flakehub: true
|
flakehub: true
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
- run: nix --experimental-features 'nix-command flakes' flake check -L
|
- run: nix flake check -L
|
||||||
|
|
||||||
vm_tests:
|
vm_tests:
|
||||||
needs: tests
|
needs: tests
|
||||||
|
|
|
@ -14,10 +14,9 @@ The following instructions assume you already have some version of Nix installed
|
||||||
|
|
||||||
## Building Nix with flakes
|
## Building Nix with flakes
|
||||||
|
|
||||||
This section assumes you are using Nix with the [`flakes`] and [`nix-command`] experimental features enabled.
|
This section assumes you are using Nix with the experimental feature [`nix-command`] enabled.
|
||||||
See the [Building Nix](#building-nix) section for equivalent instructions using stable Nix interfaces.
|
See the [Building Nix](#building-nix) section for equivalent instructions using stable Nix interfaces.
|
||||||
|
|
||||||
[`flakes`]: @docroot@/contributing/experimental-features.md#xp-feature-flakes
|
|
||||||
[`nix-command`]: @docroot@/contributing/experimental-features.md#xp-nix-command
|
[`nix-command`]: @docroot@/contributing/experimental-features.md#xp-nix-command
|
||||||
|
|
||||||
To build all dependencies and start a shell in which all environment variables are set up so that those dependencies can be found:
|
To build all dependencies and start a shell in which all environment variables are set up so that those dependencies can be found:
|
||||||
|
|
|
@ -22,7 +22,6 @@ EvalSettings evalSettings {
|
||||||
{
|
{
|
||||||
"flake",
|
"flake",
|
||||||
[](ref<Store> store, std::string_view rest) {
|
[](ref<Store> store, std::string_view rest) {
|
||||||
experimentalFeatureSettings.require(Xp::Flakes);
|
|
||||||
// FIXME `parseFlakeRef` should take a `std::string_view`.
|
// FIXME `parseFlakeRef` should take a `std::string_view`.
|
||||||
auto flakeRef = parseFlakeRef(std::string { rest }, {}, true, false);
|
auto flakeRef = parseFlakeRef(std::string { rest }, {}, true, false);
|
||||||
debug("fetching flake search path element '%s''", rest);
|
debug("fetching flake search path element '%s''", rest);
|
||||||
|
@ -229,7 +228,6 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * bas
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (hasPrefix(s, "flake:")) {
|
else if (hasPrefix(s, "flake:")) {
|
||||||
experimentalFeatureSettings.require(Xp::Flakes);
|
|
||||||
auto flakeRef = parseFlakeRef(std::string(s.substr(6)), {}, true, false);
|
auto flakeRef = parseFlakeRef(std::string(s.substr(6)), {}, true, false);
|
||||||
auto storePath = flakeRef.resolve(state.store).fetchTree(state.store).first;
|
auto storePath = flakeRef.resolve(state.store).fetchTree(state.store).first;
|
||||||
return state.rootPath(CanonPath(state.store->toRealPath(storePath)));
|
return state.rootPath(CanonPath(state.store->toRealPath(storePath)));
|
||||||
|
|
|
@ -394,9 +394,6 @@ void completeFlakeRefWithFragment(
|
||||||
|
|
||||||
void completeFlakeRef(AddCompletions & completions, ref<Store> store, std::string_view prefix)
|
void completeFlakeRef(AddCompletions & completions, ref<Store> store, std::string_view prefix)
|
||||||
{
|
{
|
||||||
if (!experimentalFeatureSettings.isEnabled(Xp::Flakes))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (prefix == "")
|
if (prefix == "")
|
||||||
completions.add(".");
|
completions.add(".");
|
||||||
|
|
||||||
|
|
|
@ -163,15 +163,11 @@ static void fetchTree(
|
||||||
}
|
}
|
||||||
input = fetchers::Input::fromAttrs(std::move(attrs));
|
input = fetchers::Input::fromAttrs(std::move(attrs));
|
||||||
} else {
|
} else {
|
||||||
if (!experimentalFeatureSettings.isEnabled(Xp::Flakes))
|
|
||||||
state.error<EvalError>(
|
|
||||||
"passing a string argument to 'fetchTree' requires the 'flakes' experimental feature"
|
|
||||||
).atPos(pos).debugThrow();
|
|
||||||
input = fetchers::Input::fromURL(url);
|
input = fetchers::Input::fromURL(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.settings.pureEval && !input.isDirect() && experimentalFeatureSettings.isEnabled(Xp::Flakes))
|
if (!state.settings.pureEval && !input.isDirect())
|
||||||
input = lookupInRegistries(state.store, input).first;
|
input = lookupInRegistries(state.store, input).first;
|
||||||
|
|
||||||
if (state.settings.pureEval && !input.isLocked()) {
|
if (state.settings.pureEval && !input.isLocked()) {
|
||||||
|
@ -383,7 +379,6 @@ static RegisterPrimOp primop_fetchTree({
|
||||||
- `"mercurial"`
|
- `"mercurial"`
|
||||||
|
|
||||||
*input* can also be a [URL-like reference](@docroot@/command-ref/new-cli/nix3-flake.md#flake-references).
|
*input* can also be a [URL-like reference](@docroot@/command-ref/new-cli/nix3-flake.md#flake-references).
|
||||||
The additional input types and the URL-like syntax requires the [`flakes` experimental feature](@docroot@/contributing/experimental-features.md#xp-feature-flakes) to be enabled.
|
|
||||||
|
|
||||||
> **Example**
|
> **Example**
|
||||||
>
|
>
|
||||||
|
@ -420,7 +415,6 @@ 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,
|
||||||
|
|
|
@ -299,11 +299,6 @@ struct GitArchiveInputScheme : InputScheme
|
||||||
input.getNarHash().has_value());
|
input.getNarHash().has_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ExperimentalFeature> experimentalFeature() const override
|
|
||||||
{
|
|
||||||
return Xp::Flakes;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
|
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
|
||||||
{
|
{
|
||||||
if (auto rev = input.getRev())
|
if (auto rev = input.getRev())
|
||||||
|
|
|
@ -102,11 +102,6 @@ struct IndirectInputScheme : InputScheme
|
||||||
throw Error("indirect input '%s' cannot be fetched directly", input.to_string());
|
throw Error("indirect input '%s' cannot be fetched directly", input.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ExperimentalFeature> experimentalFeature() const override
|
|
||||||
{
|
|
||||||
return Xp::Flakes;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isDirect(const Input & input) const override
|
bool isDirect(const Input & input) const override
|
||||||
{ return false; }
|
{ return false; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -174,11 +174,6 @@ struct PathInputScheme : InputScheme
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ExperimentalFeature> experimentalFeature() const override
|
|
||||||
{
|
|
||||||
return Xp::Flakes;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto rPathInputScheme = OnStartup([] { registerInputScheme(std::make_unique<PathInputScheme>()); });
|
static auto rPathInputScheme = OnStartup([] { registerInputScheme(std::make_unique<PathInputScheme>()); });
|
||||||
|
|
|
@ -156,7 +156,7 @@ struct RegistrySettings : Config
|
||||||
|
|
||||||
When empty, disables the global flake registry.
|
When empty, disables the global flake registry.
|
||||||
)",
|
)",
|
||||||
{}, true, Xp::Flakes};
|
{}, true};
|
||||||
};
|
};
|
||||||
|
|
||||||
RegistrySettings registrySettings;
|
RegistrySettings registrySettings;
|
||||||
|
|
|
@ -17,13 +17,7 @@ struct FlakeSettings : public Config
|
||||||
FlakeSettings();
|
FlakeSettings();
|
||||||
|
|
||||||
Setting<bool> useRegistries{
|
Setting<bool> useRegistries{
|
||||||
this,
|
this, true, "use-registries", "Whether to use flake registries to resolve flake references.", {}, true};
|
||||||
true,
|
|
||||||
"use-registries",
|
|
||||||
"Whether to use flake registries to resolve flake references.",
|
|
||||||
{},
|
|
||||||
true,
|
|
||||||
Xp::Flakes};
|
|
||||||
|
|
||||||
Setting<bool> acceptFlakeConfig{
|
Setting<bool> acceptFlakeConfig{
|
||||||
this,
|
this,
|
||||||
|
@ -31,8 +25,7 @@ struct FlakeSettings : public Config
|
||||||
"accept-flake-config",
|
"accept-flake-config",
|
||||||
"Whether to accept nix configuration from a flake without prompting.",
|
"Whether to accept nix configuration from a flake without prompting.",
|
||||||
{},
|
{},
|
||||||
true,
|
true};
|
||||||
Xp::Flakes};
|
|
||||||
|
|
||||||
Setting<std::string> commitLockFileSummary{
|
Setting<std::string> commitLockFileSummary{
|
||||||
this,
|
this,
|
||||||
|
@ -43,8 +36,7 @@ struct FlakeSettings : public Config
|
||||||
empty, the summary is generated based on the action performed.
|
empty, the summary is generated based on the action performed.
|
||||||
)",
|
)",
|
||||||
{"commit-lockfile-summary"},
|
{"commit-lockfile-summary"},
|
||||||
true,
|
true};
|
||||||
Xp::Flakes};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: don't use a global variable.
|
// TODO: don't use a global variable.
|
||||||
|
|
|
@ -343,8 +343,6 @@ LockedFlake lockFlake(
|
||||||
const FlakeRef & topRef,
|
const FlakeRef & topRef,
|
||||||
const LockFlags & lockFlags)
|
const LockFlags & lockFlags)
|
||||||
{
|
{
|
||||||
experimentalFeatureSettings.require(Xp::Flakes);
|
|
||||||
|
|
||||||
FlakeCache flakeCache;
|
FlakeCache flakeCache;
|
||||||
|
|
||||||
auto useRegistries = lockFlags.useRegistries.value_or(flakeSettings.useRegistries);
|
auto useRegistries = lockFlags.useRegistries.value_or(flakeSettings.useRegistries);
|
||||||
|
@ -744,8 +742,6 @@ void callFlake(EvalState & state,
|
||||||
const LockedFlake & lockedFlake,
|
const LockedFlake & lockedFlake,
|
||||||
Value & vRes)
|
Value & vRes)
|
||||||
{
|
{
|
||||||
experimentalFeatureSettings.require(Xp::Flakes);
|
|
||||||
|
|
||||||
auto [lockFileStr, keyMap] = lockedFlake.lockFile.to_string();
|
auto [lockFileStr, keyMap] = lockedFlake.lockFile.to_string();
|
||||||
|
|
||||||
auto overrides = state.buildBindings(lockedFlake.nodePaths.size());
|
auto overrides = state.buildBindings(lockedFlake.nodePaths.size());
|
||||||
|
@ -837,7 +833,6 @@ static RegisterPrimOp r2({
|
||||||
```
|
```
|
||||||
)",
|
)",
|
||||||
.fun = prim_getFlake,
|
.fun = prim_getFlake,
|
||||||
.experimentalFeature = Xp::Flakes,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
static void prim_parseFlakeRef(
|
static void prim_parseFlakeRef(
|
||||||
|
@ -881,7 +876,6 @@ static RegisterPrimOp r3({
|
||||||
```
|
```
|
||||||
)",
|
)",
|
||||||
.fun = prim_parseFlakeRef,
|
.fun = prim_parseFlakeRef,
|
||||||
.experimentalFeature = Xp::Flakes,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -938,7 +932,6 @@ static RegisterPrimOp r4({
|
||||||
```
|
```
|
||||||
)",
|
)",
|
||||||
.fun = prim_flakeRefToString,
|
.fun = prim_flakeRefToString,
|
||||||
.experimentalFeature = Xp::Flakes,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,11 +341,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))
|
||||||
res.insert(thisXpFeature.value());
|
res.insert(thisXpFeature.value());
|
||||||
if (thisXpFeature.value() == Xp::Flakes)
|
else if (stabilizedFeatures.count(s))
|
||||||
res.insert(Xp::FetchTree);
|
debug("experimental feature '%s' is now stable", s);
|
||||||
} else
|
else
|
||||||
warn("unknown experimental feature '%s'", s);
|
warn("unknown experimental feature '%s'", s);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -386,7 +386,7 @@ struct ExperimentalFeatureSettings : Config {
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```
|
```
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command
|
||||||
```
|
```
|
||||||
|
|
||||||
The following experimental features are available:
|
The following experimental features are available:
|
||||||
|
|
|
@ -70,19 +70,12 @@ constexpr std::array<ExperimentalFeatureDetails, numXpFeatures> xpFeatureDetails
|
||||||
)",
|
)",
|
||||||
.trackingUrl = "https://github.com/NixOS/nix/milestone/42",
|
.trackingUrl = "https://github.com/NixOS/nix/milestone/42",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.tag = Xp::Flakes,
|
|
||||||
.name = "flakes",
|
|
||||||
.description = R"(
|
|
||||||
Enable flakes. See the manual entry for [`nix
|
|
||||||
flake`](@docroot@/command-ref/new-cli/nix3-flake.md) for details.
|
|
||||||
)",
|
|
||||||
.trackingUrl = "https://github.com/NixOS/nix/milestone/27",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.tag = Xp::FetchTree,
|
.tag = Xp::FetchTree,
|
||||||
.name = "fetch-tree",
|
.name = "fetch-tree",
|
||||||
.description = R"(
|
.description = R"(
|
||||||
|
*Enabled for Determinate Nix Installer users since 2.24*
|
||||||
|
|
||||||
Enable the use of the [`fetchTree`](@docroot@/language/builtins.md#builtins-fetchTree) built-in function in the Nix language.
|
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.
|
`fetchTree` exposes a generic interface for fetching remote file system trees from different types of remote sources.
|
||||||
|
@ -305,6 +298,12 @@ static_assert(
|
||||||
}(),
|
}(),
|
||||||
"array order does not match enum tag order");
|
"array order does not match enum tag order");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A set of previously experimental features that are now considered
|
||||||
|
* stable. We don't warn if users have these in `experimental-features`.
|
||||||
|
*/
|
||||||
|
std::set<std::string> stabilizedFeatures{"flakes"};
|
||||||
|
|
||||||
const std::optional<ExperimentalFeature> parseExperimentalFeature(const std::string_view & name)
|
const std::optional<ExperimentalFeature> parseExperimentalFeature(const std::string_view & name)
|
||||||
{
|
{
|
||||||
using ReverseXpMap = std::map<std::string_view, ExperimentalFeature>;
|
using ReverseXpMap = std::map<std::string_view, ExperimentalFeature>;
|
||||||
|
|
|
@ -19,7 +19,6 @@ enum struct ExperimentalFeature
|
||||||
{
|
{
|
||||||
CaDerivations,
|
CaDerivations,
|
||||||
ImpureDerivations,
|
ImpureDerivations,
|
||||||
Flakes,
|
|
||||||
FetchTree,
|
FetchTree,
|
||||||
NixCommand,
|
NixCommand,
|
||||||
GitHashing,
|
GitHashing,
|
||||||
|
@ -38,6 +37,8 @@ enum struct ExperimentalFeature
|
||||||
VerifiedFetches,
|
VerifiedFetches,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern std::set<std::string> stabilizedFeatures;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just because writing `ExperimentalFeature::CaDerivations` is way too long
|
* Just because writing `ExperimentalFeature::CaDerivations` is way too long
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1462,12 +1462,6 @@ struct CmdFlake : NixMultiCommand
|
||||||
#include "flake.md"
|
#include "flake.md"
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run() override
|
|
||||||
{
|
|
||||||
experimentalFeatureSettings.require(Xp::Flakes);
|
|
||||||
NixMultiCommand::run();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto rCmdFlake = registerCommand<CmdFlake>("flake");
|
static auto rCmdFlake = registerCommand<CmdFlake>("flake");
|
||||||
|
|
|
@ -412,7 +412,6 @@ void mainWrapped(int argc, char * * argv)
|
||||||
|
|
||||||
if (argc == 2 && std::string(argv[1]) == "__dump-language") {
|
if (argc == 2 && std::string(argv[1]) == "__dump-language") {
|
||||||
experimentalFeatureSettings.experimentalFeatures = {
|
experimentalFeatureSettings.experimentalFeatures = {
|
||||||
Xp::Flakes,
|
|
||||||
Xp::FetchClosure,
|
Xp::FetchClosure,
|
||||||
Xp::DynamicDerivations,
|
Xp::DynamicDerivations,
|
||||||
Xp::FetchTree,
|
Xp::FetchTree,
|
||||||
|
|
|
@ -69,11 +69,9 @@ That is, Nix will operate on the default flake output attribute of the flake in
|
||||||
### Flake output attribute
|
### Flake output attribute
|
||||||
|
|
||||||
> **Warning** \
|
> **Warning** \
|
||||||
> Flake output attribute installables depend on both the
|
> Flake output attribute installables depend on the
|
||||||
> [`flakes`](@docroot@/contributing/experimental-features.md#xp-feature-flakes)
|
|
||||||
> and
|
|
||||||
> [`nix-command`](@docroot@/contributing/experimental-features.md#xp-feature-nix-command)
|
> [`nix-command`](@docroot@/contributing/experimental-features.md#xp-feature-nix-command)
|
||||||
> experimental features, and subject to change without notice.
|
> experimental feature, and subject to change without notice.
|
||||||
|
|
||||||
Example: `nixpkgs#hello`
|
Example: `nixpkgs#hello`
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ R""(
|
||||||
Loading Installable ''...
|
Loading Installable ''...
|
||||||
Added 1 variables.
|
Added 1 variables.
|
||||||
|
|
||||||
# nix repl --extra-experimental-features 'flakes' nixpkgs
|
# nix repl nixpkgs
|
||||||
Loading Installable 'flake:nixpkgs#'...
|
Loading Installable 'flake:nixpkgs#'...
|
||||||
Added 5 variables.
|
Added 5 variables.
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ source common.sh
|
||||||
|
|
||||||
requireDaemonNewerThan "2.4pre20210626"
|
requireDaemonNewerThan "2.4pre20210626"
|
||||||
|
|
||||||
enableFeatures "ca-derivations nix-command flakes"
|
enableFeatures "ca-derivations nix-command"
|
||||||
|
|
||||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
cd ..
|
cd ..
|
||||||
|
|
|
@ -12,7 +12,7 @@ if isTestOnNixOS; then
|
||||||
! test -e "$test_nix_conf"
|
! test -e "$test_nix_conf"
|
||||||
cat > "$test_nix_conf_dir/nix.conf" <<EOF
|
cat > "$test_nix_conf_dir/nix.conf" <<EOF
|
||||||
# TODO: this is not needed for all tests and prevents stable commands from be tested in isolation
|
# TODO: this is not needed for all tests and prevents stable commands from be tested in isolation
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command
|
||||||
flake-registry = $TEST_ROOT/registry.json
|
flake-registry = $TEST_ROOT/registry.json
|
||||||
show-trace = true
|
show-trace = true
|
||||||
EOF
|
EOF
|
||||||
|
@ -58,7 +58,6 @@ EOF
|
||||||
|
|
||||||
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
|
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
|
||||||
fsync-metadata = false
|
fsync-metadata = false
|
||||||
extra-experimental-features = flakes
|
|
||||||
!include nix.conf.extra.not-there
|
!include nix.conf.extra.not-there
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
|
@ -59,13 +59,11 @@ var=$(nix config show | grep '^experimental-features =' | cut -d '=' -f 2 | xarg
|
||||||
|
|
||||||
# Test that it's possible to load config from the environment
|
# Test that it's possible to load config from the environment
|
||||||
prev=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs)
|
prev=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs)
|
||||||
export NIX_CONFIG="cores = 4242"$'\n'"experimental-features = nix-command flakes"
|
export NIX_CONFIG="cores = 4242"$'\n'"experimental-features = nix-command"
|
||||||
exp_cores=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs)
|
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)
|
exp_features=$(nix config show | grep '^experimental-features' | cut -d '=' -f 2 | xargs)
|
||||||
[[ $prev != $exp_cores ]]
|
[[ $prev != $exp_cores ]]
|
||||||
[[ $exp_cores == "4242" ]]
|
[[ $exp_cores == "4242" ]]
|
||||||
# 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 config show | grep '^warn-dirty' | cut -d '=' -f 2 | xargs)
|
val=$(nix config show | grep '^warn-dirty' | cut -d '=' -f 2 | xargs)
|
||||||
|
|
|
@ -12,11 +12,11 @@ source common.sh
|
||||||
#
|
#
|
||||||
# function grep_both_ways {
|
# function grep_both_ways {
|
||||||
# nix --experimental-features 'nix-command' "$@" | grepQuietInverse flake
|
# nix --experimental-features 'nix-command' "$@" | grepQuietInverse flake
|
||||||
# nix --experimental-features 'nix-command flakes' "$@" | grepQuiet flake
|
# nix --experimental-features 'nix-command' "$@" | grepQuiet flake
|
||||||
#
|
#
|
||||||
# # Also, the order should not matter
|
# # Also, the order should not matter
|
||||||
# nix "$@" --experimental-features 'nix-command' | grepQuietInverse flake
|
# nix "$@" --experimental-features 'nix-command' | grepQuietInverse flake
|
||||||
# nix "$@" --experimental-features 'nix-command flakes' | grepQuiet flake
|
# nix "$@" --experimental-features 'nix-command' | grepQuiet flake
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# # Simple case, the configuration effects the running command
|
# # Simple case, the configuration effects the running command
|
||||||
|
@ -29,50 +29,50 @@ source common.sh
|
||||||
# with a warning if the experimental feature is not enabled. The order of the
|
# with a warning if the experimental feature is not enabled. The order of the
|
||||||
# `setting = value` lines in the configuration should not matter.
|
# `setting = value` lines in the configuration should not matter.
|
||||||
|
|
||||||
# 'flakes' experimental-feature is disabled before, ignore and warn
|
xpFeature=auto-allocate-uids
|
||||||
NIX_CONFIG='
|
gatedSetting=auto-allocate-uids
|
||||||
|
|
||||||
|
# Experimental feature is disabled before, ignore and warn.
|
||||||
|
NIX_CONFIG="
|
||||||
experimental-features = nix-command
|
experimental-features = nix-command
|
||||||
accept-flake-config = true
|
$gatedSetting = true
|
||||||
' expect 1 nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
" expect 1 nix config show $gatedSetting 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
||||||
[[ $(cat "$TEST_ROOT/stdout") = '' ]]
|
[[ $(cat "$TEST_ROOT/stdout") = '' ]]
|
||||||
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" "$TEST_ROOT/stderr"
|
grepQuiet "error: could not find setting '$gatedSetting'" "$TEST_ROOT/stderr"
|
||||||
grepQuiet "error: could not find setting 'accept-flake-config'" "$TEST_ROOT/stderr"
|
|
||||||
|
|
||||||
# 'flakes' experimental-feature is disabled after, ignore and warn
|
# Experimental feature is disabled after, ignore and warn.
|
||||||
NIX_CONFIG='
|
NIX_CONFIG="
|
||||||
accept-flake-config = true
|
$gatedSetting = true
|
||||||
experimental-features = nix-command
|
experimental-features = nix-command
|
||||||
' expect 1 nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
" expect 1 nix config show $gatedSetting 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
||||||
[[ $(cat "$TEST_ROOT/stdout") = '' ]]
|
[[ $(cat "$TEST_ROOT/stdout") = '' ]]
|
||||||
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" "$TEST_ROOT/stderr"
|
grepQuiet "error: could not find setting '$gatedSetting'" "$TEST_ROOT/stderr"
|
||||||
grepQuiet "error: could not find setting 'accept-flake-config'" "$TEST_ROOT/stderr"
|
|
||||||
|
|
||||||
# 'flakes' experimental-feature is enabled before, process
|
# Experimental feature is enabled before, process.
|
||||||
NIX_CONFIG='
|
NIX_CONFIG="
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command $xpFeature
|
||||||
accept-flake-config = true
|
$gatedSetting = true
|
||||||
' nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
" nix config show $gatedSetting 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
||||||
grepQuiet "true" "$TEST_ROOT/stdout"
|
grepQuiet "true" "$TEST_ROOT/stdout"
|
||||||
grepQuietInverse "Ignoring setting 'accept-flake-config'" "$TEST_ROOT/stderr"
|
|
||||||
|
|
||||||
# 'flakes' experimental-feature is enabled after, process
|
# Experimental feature is enabled after, process.
|
||||||
NIX_CONFIG='
|
NIX_CONFIG="
|
||||||
accept-flake-config = true
|
$gatedSetting = true
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command $xpFeature
|
||||||
' nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
" nix config show $gatedSetting 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
||||||
grepQuiet "true" "$TEST_ROOT/stdout"
|
grepQuiet "true" "$TEST_ROOT/stdout"
|
||||||
grepQuietInverse "Ignoring setting 'accept-flake-config'" "$TEST_ROOT/stderr"
|
grepQuietInverse "Ignoring setting '$gatedSetting'" "$TEST_ROOT/stderr"
|
||||||
|
|
||||||
function exit_code_both_ways {
|
function exit_code_both_ways {
|
||||||
expect 1 nix --experimental-features 'nix-command ' "$@" 1>/dev/null
|
expect 1 nix --experimental-features 'nix-command ' "$@" 1>/dev/null
|
||||||
nix --experimental-features 'nix-command flakes' "$@" 1>/dev/null
|
nix --experimental-features "nix-command $xpFeature" "$@" 1>/dev/null
|
||||||
|
|
||||||
# Also, the order should not matter
|
# Also, the order should not matter
|
||||||
expect 1 nix "$@" --experimental-features 'nix-command' 1>/dev/null
|
expect 1 nix "$@" --experimental-features 'nix-command' 1>/dev/null
|
||||||
nix "$@" --experimental-features 'nix-command flakes' 1>/dev/null
|
nix "$@" --experimental-features "nix-command $xpFeature" 1>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_code_both_ways show-config --flake-registry 'https://no'
|
exit_code_both_ways config show --auto-allocate-uids
|
||||||
|
|
||||||
# Double check these are stable
|
# Double check these are stable
|
||||||
nix --experimental-features '' --help 1>/dev/null
|
nix --experimental-features '' --help 1>/dev/null
|
||||||
|
|
|
@ -140,9 +140,9 @@ EOF
|
||||||
testReplResponse '
|
testReplResponse '
|
||||||
foo + baz
|
foo + baz
|
||||||
' "3" \
|
' "3" \
|
||||||
./flake ./flake\#bar --experimental-features 'flakes'
|
./flake ./flake\#bar
|
||||||
|
|
||||||
# Test the `:reload` mechansim with flakes:
|
# Test the `:reload` mechanism with flakes:
|
||||||
# - Eval `./flake#changingThing`
|
# - Eval `./flake#changingThing`
|
||||||
# - Modify the flake
|
# - Modify the flake
|
||||||
# - Re-eval it
|
# - Re-eval it
|
||||||
|
@ -153,7 +153,7 @@ sleep 1 # Leave the repl the time to eval 'foo'
|
||||||
sed -i 's/beforeChange/afterChange/' flake/flake.nix
|
sed -i 's/beforeChange/afterChange/' flake/flake.nix
|
||||||
echo ":reload"
|
echo ":reload"
|
||||||
echo "changingThing"
|
echo "changingThing"
|
||||||
) | nix repl ./flake --experimental-features 'flakes')
|
) | nix repl ./flake)
|
||||||
echo "$replResult" | grepQuiet -s beforeChange
|
echo "$replResult" | grepQuiet -s beforeChange
|
||||||
echo "$replResult" | grepQuiet -s afterChange
|
echo "$replResult" | grepQuiet -s afterChange
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ in
|
||||||
virtualisation.additionalPaths = [ pkgs.hello pkgs.fuse ];
|
virtualisation.additionalPaths = [ pkgs.hello pkgs.fuse ];
|
||||||
virtualisation.memorySize = 4096;
|
virtualisation.memorySize = 4096;
|
||||||
nix.settings.substituters = lib.mkForce [ ];
|
nix.settings.substituters = lib.mkForce [ ];
|
||||||
nix.extraOptions = "experimental-features = nix-command flakes";
|
nix.extraOptions = "experimental-features = nix-command";
|
||||||
networking.hosts.${(builtins.head nodes.github.networking.interfaces.eth1.ipv4.addresses).address} =
|
networking.hosts.${(builtins.head nodes.github.networking.interfaces.eth1.ipv4.addresses).address} =
|
||||||
[ "channels.nixos.org" "api.github.com" "github.com" ];
|
[ "channels.nixos.org" "api.github.com" "github.com" ];
|
||||||
security.pki.certificateFiles = [ "${cert}/ca.crt" ];
|
security.pki.certificateFiles = [ "${cert}/ca.crt" ];
|
||||||
|
|
|
@ -104,7 +104,7 @@ in
|
||||||
virtualisation.memorySize = 4096;
|
virtualisation.memorySize = 4096;
|
||||||
nix.settings.substituters = lib.mkForce [ ];
|
nix.settings.substituters = lib.mkForce [ ];
|
||||||
nix.extraOptions = ''
|
nix.extraOptions = ''
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command
|
||||||
flake-registry = https://git.sr.ht/~NixOS/flake-registry/blob/master/flake-registry.json
|
flake-registry = https://git.sr.ht/~NixOS/flake-registry/blob/master/flake-registry.json
|
||||||
'';
|
'';
|
||||||
environment.systemPackages = [ pkgs.jq ];
|
environment.systemPackages = [ pkgs.jq ];
|
||||||
|
|
|
@ -51,7 +51,7 @@ in
|
||||||
virtualisation.additionalPaths = [ pkgs.hello pkgs.fuse ];
|
virtualisation.additionalPaths = [ pkgs.hello pkgs.fuse ];
|
||||||
virtualisation.memorySize = 4096;
|
virtualisation.memorySize = 4096;
|
||||||
nix.settings.substituters = lib.mkForce [ ];
|
nix.settings.substituters = lib.mkForce [ ];
|
||||||
nix.extraOptions = "experimental-features = nix-command flakes";
|
nix.extraOptions = "experimental-features = nix-command";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ namespace nix {
|
||||||
"description",
|
"description",
|
||||||
{},
|
{},
|
||||||
true,
|
true,
|
||||||
Xp::Flakes,
|
Xp::CaDerivations,
|
||||||
};
|
};
|
||||||
setting.assign("value");
|
setting.assign("value");
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ namespace nix {
|
||||||
"description": "description\n",
|
"description": "description\n",
|
||||||
"documentDefault": true,
|
"documentDefault": true,
|
||||||
"value": "value",
|
"value": "value",
|
||||||
"experimentalFeature": "flakes"
|
"experimentalFeature": "ca-derivations"
|
||||||
}
|
}
|
||||||
})#"_json);
|
})#"_json);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue