aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/globals.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-11-26 19:48:34 +0100
committerEelco Dolstra <edolstra@gmail.com>2019-11-26 19:48:34 +0100
commit1ec6e6e11e2dbca8803305757d472dabe5878129 (patch)
tree52f52b3be3bf1de7082f7eefc20fb6087c022af7 /src/libstore/globals.cc
parentfc62caa4a5f9aa26d6381e517e9e5567f76e5082 (diff)
Add feature to disable URL literals
E.g. $ nix-build '<nixpkgs>' -A hello --experimental-features no-url-literals error: URL literals are disabled, at /nix/store/vsjamkzh15r3c779q2711az826hqgvzr-nixpkgs-20.03pre194957.bef773ed53f/nixpkgs/pkgs/top-level/all-packages.nix:1236:11 Helps with implementing https://github.com/NixOS/rfcs/pull/45.
Diffstat (limited to 'src/libstore/globals.cc')
-rw-r--r--src/libstore/globals.cc9
1 files changed, 7 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);
}