aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/globals.cc9
-rw-r--r--src/libstore/globals.hh2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index aa0823f41..6d3b95740 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -105,10 +105,15 @@ StringSet Settings::getDefaultSystemFeatures()
return features;
}
-void Settings::requireExperimentalFeature(const std::string & name)
+bool Settings::isExperimentalFeatureEnabled(const std::string & name)
{
auto & f = experimentalFeatures.get();
- if (std::find(f.begin(), f.end(), name) == f.end())
+ return std::find(f.begin(), f.end(), name) != f.end();
+}
+
+void Settings::requireExperimentalFeature(const std::string & name)
+{
+ if (!isExperimentalFeatureEnabled(name))
throw Error("experimental Nix feature '%s' is disabled", name);
}
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index 3eb2f698c..9f395425a 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -357,6 +357,8 @@ public:
Setting<Strings> experimentalFeatures{this, {}, "experimental-features",
"Experimental Nix features to enable."};
+ bool isExperimentalFeatureEnabled(const std::string & name);
+
void requireExperimentalFeature(const std::string & name);
};