aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-10-16 17:45:09 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-10-21 13:34:44 +0200
commitaabf5c86c9df1b4e1616a4cf06ee14a6edf2e5e1 (patch)
treed571b6fc195967fef1f54696151594119b74f632 /src
parent389a2cebed7cd72bda524ece0a56af2888cd80b6 (diff)
Add experimental-features setting
Experimental features are now opt-in. There is currently one experimental feature: "nix-command" (which enables the "nix" command. This will allow us to merge experimental features more quickly, without committing to supporting them indefinitely. Typical usage: $ nix build --experimental-features 'nix-command flakes' nixpkgs#hello (cherry picked from commit 8e478c234100cf03ea1b777d4bd42a9be7be9e8c, without the "flakes" feature)
Diffstat (limited to 'src')
-rw-r--r--src/libstore/globals.cc7
-rw-r--r--src/libstore/globals.hh5
-rw-r--r--src/nix/main.cc2
3 files changed, 14 insertions, 0 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index 1c2c08715..249c36673 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -105,6 +105,13 @@ StringSet Settings::getDefaultSystemFeatures()
return features;
}
+void Settings::requireExperimentalFeature(const std::string & name)
+{
+ auto & f = experimentalFeatures.get();
+ if (std::find(f.begin(), f.end(), name) == f.end())
+ throw Error("experimental Nix feature '%s' is disabled", name);
+}
+
const string nixVersion = PACKAGE_VERSION;
template<> void BaseSetting<SandboxMode>::set(const std::string & str)
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index ab1c09aa2..1221e4db7 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -353,6 +353,11 @@ public:
Setting<Paths> pluginFiles{this, {}, "plugin-files",
"Plugins to dynamically load at nix initialization time."};
+
+ Setting<Strings> experimentalFeatures{this, {}, "experimental-features",
+ "Experimental Nix features to enable."};
+
+ void requireExperimentalFeature(const std::string & name);
};
diff --git a/src/nix/main.cc b/src/nix/main.cc
index a80fd0ea6..22f5e8c4c 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -138,6 +138,8 @@ void mainWrapped(int argc, char * * argv)
args.parseCmdline(argvToStrings(argc, argv));
+ settings.requireExperimentalFeature("nix-command");
+
initPlugins();
if (!args.command) args.showHelpAndExit();