aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/config.hh
diff options
context:
space:
mode:
authorpiegames <git@piegames.de>2024-07-13 05:24:41 +0200
committerpiegames <git@piegames.de>2024-08-17 19:47:51 +0200
commit49d61b2e4bf338042364c85d3c2ead0b33963e65 (patch)
tree09ffba6841df5a3990aa2d1c6bb9e19e0e355b14 /src/libutil/config.hh
parent1c080a8239f1be5a61d9fb2121ca958542ec183f (diff)
libexpr: Introduce Deprecated features
They are like experimental features, but opt-in instead of opt-out. They will allow us to gracefully remove language features. See #437 Change-Id: I9ca04cc48e6926750c4d622c2b229b25cc142c42
Diffstat (limited to 'src/libutil/config.hh')
-rw-r--r--src/libutil/config.hh43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/libutil/config.hh b/src/libutil/config.hh
index d7bf9cdc9..a0ad125fb 100644
--- a/src/libutil/config.hh
+++ b/src/libutil/config.hh
@@ -9,6 +9,7 @@
#include "types.hh"
#include "experimental-features.hh"
+#include "deprecated-features.hh"
namespace nix {
@@ -441,7 +442,7 @@ struct GlobalConfig : public AbstractConfig
extern GlobalConfig globalConfig;
-struct ExperimentalFeatureSettings : Config {
+struct FeatureSettings : Config {
Setting<std::set<ExperimentalFeature>> experimentalFeatures{
this, {}, "experimental-features",
@@ -483,9 +484,47 @@ struct ExperimentalFeatureSettings : Config {
* disabled, and so the function does nothing in that case.
*/
void require(const std::optional<ExperimentalFeature> &) const;
+
+ Setting<std::set<DeprecatedFeature>> deprecatedFeatures{
+ this, {}, "deprecated-features",
+ R"(
+ Deprecated features that are allowed. (Currently there are none.)
+
+ The following deprecated feature features can be re-activated:
+
+ {{#include @generated@/command-ref/deprecated-features-shortlist.md}}
+
+ Deprecated features are [further documented in the manual](@docroot@/contributing/deprecated-features.md).
+ )"};
+
+ /**
+ * Check whether the given deprecated feature is enabled.
+ */
+ bool isEnabled(const DeprecatedFeature &) const;
+
+ /**
+ * Require an deprecated feature be enabled, throwing an error if it is
+ * not.
+ */
+ void require(const DeprecatedFeature &) const;
+
+ /**
+ * `std::nullopt` pointer means no feature, which means there is nothing that could be
+ * disabled, and so the function returns true in that case.
+ */
+ bool isEnabled(const std::optional<DeprecatedFeature> &) const;
+
+ /**
+ * `std::nullopt` pointer means no feature, which means there is nothing that could be
+ * disabled, and so the function does nothing in that case.
+ */
+ void require(const std::optional<DeprecatedFeature> &) const;
};
// FIXME: don't use a global variable.
-extern ExperimentalFeatureSettings experimentalFeatureSettings;
+extern FeatureSettings& featureSettings;
+// Aliases to `featureSettings` for not having to change the name in the code everywhere
+using ExperimentalFeatureSettings = FeatureSettings;
+extern FeatureSettings experimentalFeatureSettings;
}