aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2021-10-25 15:53:01 +0200
committerregnat <rg@regnat.ovh>2021-10-26 07:02:31 +0200
commitaf99941279b80c962ec9cae3e5fa32976a3f5744 (patch)
tree034ffb01457354b07e9b6dac02892e1b5d8fca09 /src/nix
parent4a2b7cc68c7d11ec126bc412ffea838e629345af (diff)
Make experimental-features a proper type
Rather than having them plain strings scattered through the whole codebase, create an enum containing all the known experimental features. This means that - Nix can now `warn` when an unkwown experimental feature is passed (making it much nicer to spot typos and spot deprecated features) - It’s now easy to remove a feature altogether (once the feature isn’t experimental anymore or is dropped) by just removing the field for the enum and letting the compiler point us to all the now invalid usages of it.
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/develop.cc2
-rw-r--r--src/nix/flake.cc2
-rw-r--r--src/nix/main.cc2
-rw-r--r--src/nix/realisation.cc2
-rw-r--r--src/nix/sigs.cc2
5 files changed, 5 insertions, 5 deletions
diff --git a/src/nix/develop.cc b/src/nix/develop.cc
index f22335023..5aad53919 100644
--- a/src/nix/develop.cc
+++ b/src/nix/develop.cc
@@ -195,7 +195,7 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
'buildDerivation', but that's privileged. */
drv.name += "-env";
drv.inputSrcs.insert(std::move(getEnvShPath));
- if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
+ if (settings.isExperimentalFeatureEnabled(Xp::CaDerivations)) {
for (auto & output : drv.outputs) {
output.second = {
.output = DerivationOutputDeferred{},
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 7e4d23f6e..68bb76742 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -1138,7 +1138,7 @@ struct CmdFlake : NixMultiCommand
{
if (!command)
throw UsageError("'nix flake' requires a sub-command.");
- settings.requireExperimentalFeature("flakes");
+ settings.requireExperimentalFeature(Xp::Flakes);
command->second->prepare();
command->second->run();
}
diff --git a/src/nix/main.cc b/src/nix/main.cc
index 2c3976689..1e033f4f2 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -337,7 +337,7 @@ void mainWrapped(int argc, char * * argv)
if (args.command->first != "repl"
&& args.command->first != "doctor"
&& args.command->first != "upgrade-nix")
- settings.requireExperimentalFeature("nix-command");
+ settings.requireExperimentalFeature(Xp::NixCommand);
if (args.useNet && !haveInternet()) {
warn("you don't have Internet access; disabling some network-dependent features");
diff --git a/src/nix/realisation.cc b/src/nix/realisation.cc
index dfa8ff449..c9a7157cd 100644
--- a/src/nix/realisation.cc
+++ b/src/nix/realisation.cc
@@ -46,7 +46,7 @@ struct CmdRealisationInfo : BuiltPathsCommand, MixJSON
void run(ref<Store> store, BuiltPaths && paths) override
{
- settings.requireExperimentalFeature("ca-derivations");
+ settings.requireExperimentalFeature(Xp::CaDerivations);
RealisedPath::Set realisations;
for (auto & builtPath : paths) {
diff --git a/src/nix/sigs.cc b/src/nix/sigs.cc
index 43e0d9148..6a238efbe 100644
--- a/src/nix/sigs.cc
+++ b/src/nix/sigs.cc
@@ -219,7 +219,7 @@ struct CmdKey : NixMultiCommand
{
if (!command)
throw UsageError("'nix flake' requires a sub-command.");
- settings.requireExperimentalFeature("flakes");
+ settings.requireExperimentalFeature(Xp::Flakes);
command->second->prepare();
command->second->run();
}