diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index bee94cbd8..edaa3a822 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -2,6 +2,7 @@ #include "util.hh" #include "archive.hh" #include "args.hh" +#include "sync.hh" #include #include @@ -129,8 +130,14 @@ bool Settings::isExperimentalFeatureEnabled(const std::string & name) void Settings::requireExperimentalFeature(const std::string & name) { - if (!isExperimentalFeatureEnabled(name)) - throw Error("experimental Nix feature '%1%' is disabled; use '--experimental-features %1%' to override", name); + if (!isExperimentalFeatureEnabled(name)) { + if (allowExperimentalFeatures) { + static Sync> warned; + if (warned.lock()->insert(name).second) + warn("feature '%s' is experimental", name); + } else + throw Error("experimental Nix feature '%1%' is disabled; use '--experimental-features %1%' to override", name); + } } bool Settings::isWSL1() diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 2fbcafff8..617b0cc5b 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -357,6 +357,10 @@ public: Setting githubAccessToken{this, "", "github-access-token", "GitHub access token to get access to GitHub data through the GitHub API for github:<..> flakes."}; + Setting allowExperimentalFeatures{this, true, "allow-experimental-features", + "Whether the use of experimental features other than those listed in " + "the option 'experimental-features' gives a warning rather than fatal error."}; + Setting experimentalFeatures{this, {}, "experimental-features", "Experimental Nix features to enable."};