From 278fddc317cf0cf4d3602d0ec0f24d1dd281fadb Mon Sep 17 00:00:00 2001 From: piegames Date: Sat, 13 Jul 2024 07:55:17 +0200 Subject: libexpr: Deprecate URL literals Closes #437. Change-Id: I9f67fc965bb4a7e7fd849e5067ac1cb3bab064cd --- src/libexpr/parser/parser.cc | 6 +++--- src/libutil/config.hh | 8 +++++++- src/libutil/deprecated-features.cc | 9 ++++++++- src/libutil/deprecated-features.hh | 1 + 4 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/libexpr/parser/parser.cc b/src/libexpr/parser/parser.cc index e45776ca6..d57c33a30 100644 --- a/src/libexpr/parser/parser.cc +++ b/src/libexpr/parser/parser.cc @@ -656,10 +656,10 @@ template<> struct BuildAST : p::maybe_nothing {}; template<> struct BuildAST { static void apply(const auto & in, ExprState & s, State & ps) { - bool noURLLiterals = ps.featureSettings.isEnabled(Xp::NoUrlLiterals); - if (noURLLiterals) + bool URLLiterals = ps.featureSettings.isEnabled(Dep::UrlLiterals); + if (!URLLiterals) throw ParseError({ - .msg = HintFmt("URL literals are disabled"), + .msg = HintFmt("URL literals are deprecated, allow using them with --extra-deprecated-features=url-literals"), .pos = ps.positions[ps.at(in)] }); s.pushExpr(ps.at(in), in.string()); diff --git a/src/libutil/config.hh b/src/libutil/config.hh index a0ad125fb..36e42fe63 100644 --- a/src/libutil/config.hh +++ b/src/libutil/config.hh @@ -488,7 +488,13 @@ struct FeatureSettings : Config { Setting> deprecatedFeatures{ this, {}, "deprecated-features", R"( - Deprecated features that are allowed. (Currently there are none.) + Deprecated features that are allowed. + + Example: + + ``` + deprecated-features = url-literals + ``` The following deprecated feature features can be re-activated: diff --git a/src/libutil/deprecated-features.cc b/src/libutil/deprecated-features.cc index 7c59d8598..11b6c42bd 100644 --- a/src/libutil/deprecated-features.cc +++ b/src/libutil/deprecated-features.cc @@ -24,9 +24,16 @@ struct DeprecatedFeatureDetails * feature, we either have no issue at all if few features are not added * at the end of the list, or a proper merge conflict if they are. */ -constexpr size_t numDepFeatures = 0; +constexpr size_t numDepFeatures = 1 + static_cast(Dep::UrlLiterals); constexpr std::array depFeatureDetails = {{ + { + .tag = Dep::UrlLiterals, + .name = "url-literals", + .description = R"( + Allow unquoted URLs as part of the Nix language syntax. + )", + }, }}; static_assert( diff --git a/src/libutil/deprecated-features.hh b/src/libutil/deprecated-features.hh index 86a9b8a5a..c00a5d7bd 100644 --- a/src/libutil/deprecated-features.hh +++ b/src/libutil/deprecated-features.hh @@ -18,6 +18,7 @@ namespace nix { */ enum struct DeprecatedFeature { + UrlLiterals }; /** -- cgit v1.2.3