diff --git a/doc/manual/rl-next/deprecated-features.md b/doc/manual/rl-next/deprecated-features.md
new file mode 100644
index 000000000..d800ac248
--- /dev/null
+++ b/doc/manual/rl-next/deprecated-features.md
@@ -0,0 +1,12 @@
+---
+synopsis: Deprecated URL literals
+issues: [fj#437]
+cls: [1736, 1735, 1744]
+category: Breaking Changes
+credits: [piegames, horrors]
+---
+
+URL literals have long been obsolete and discouraged of use, and now they are officially deprecated.
+This means that all URLs must be properly put within quotes like all other strings.
+
+To ease migration, they can still be enabled with `--extra-deprecated-features url-literals` for now.
diff --git a/doc/manual/src/language/values.md b/doc/manual/src/language/values.md
index aa5455ae2..30d2169ca 100644
--- a/doc/manual/src/language/values.md
+++ b/doc/manual/src/language/values.md
@@ -77,12 +77,6 @@
}
```
- Finally, as a convenience, *URIs* as defined in appendix B of
- [RFC 2396](http://www.ietf.org/rfc/rfc2396.txt) can be written *as
- is*, without quotes. For instance, the string
- `"http://example.org/foo.tar.bz2"` can also be written as
- `http://example.org/foo.tar.bz2`.
-
- Number
Numbers, which can be *integers* (like `123`) or *floating point*
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
};
/**
diff --git a/tests/functional/lang.sh b/tests/functional/lang.sh
index 94c00bad0..aa41b41d8 100755
--- a/tests/functional/lang.sh
+++ b/tests/functional/lang.sh
@@ -53,8 +53,13 @@ done
for i in lang/parse-okay-*.nix; do
echo "parsing $i (should succeed)";
i=$(basename "$i" .nix)
+ # Hard-code that these two files are allowed to use url literals (because they test them)
+ if [[ "$i" == "parse-okay-url" || "$i" == "parse-okay-regression-20041027" ]]
+ then
+ extraArgs="--extra-deprecated-features url-literals"
+ fi
if
- expect 0 nix-instantiate --parse - < "lang/$i.nix" \
+ expect 0 nix-instantiate --parse ${extraArgs-} - < "lang/$i.nix" \
1> "lang/$i.out" \
2> "lang/$i.err"
then
diff --git a/tests/functional/lang/parse-okay-regression-20041027.nix b/tests/functional/lang/parse-okay-regression-20041027.nix
index ae2e256ee..541264b16 100644
--- a/tests/functional/lang/parse-okay-regression-20041027.nix
+++ b/tests/functional/lang/parse-okay-regression-20041027.nix
@@ -1,3 +1,4 @@
+# This test needs to be run with --extra-deprecated-features url-literals
{stdenv, fetchurl /* pkgconfig, libX11 */ }:
stdenv.mkDerivation {
diff --git a/tests/functional/lang/parse-okay-url.nix b/tests/functional/lang/parse-okay-url.nix
index 08de27d0a..f74a72bb1 100644
--- a/tests/functional/lang/parse-okay-url.nix
+++ b/tests/functional/lang/parse-okay-url.nix
@@ -1,3 +1,4 @@
+# This test needs to be run with --extra-deprecated-features url-literals
[ x:x
https://svn.cs.uu.nl:12443/repos/trace/trunk
http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2
diff --git a/tests/unit/libexpr/trivial.cc b/tests/unit/libexpr/trivial.cc
index 46f9b7499..905e258bc 100644
--- a/tests/unit/libexpr/trivial.cc
+++ b/tests/unit/libexpr/trivial.cc
@@ -87,15 +87,15 @@ namespace nix {
}
TEST_F(TrivialExpressionTest, urlLiteral) {
- auto v = eval("https://nixos.org");
+ FeatureSettings mockFeatureSettings;
+ mockFeatureSettings.set("deprecated-features", "url-literals");
+
+ auto v = eval("https://nixos.org", true, mockFeatureSettings);
ASSERT_THAT(v, IsStringEq("https://nixos.org"));
}
TEST_F(TrivialExpressionTest, noUrlLiteral) {
- ExperimentalFeatureSettings mockXpSettings;
- mockXpSettings.set("experimental-features", "no-url-literals");
-
- ASSERT_THROW(eval("https://nixos.org", true, mockXpSettings), Error);
+ ASSERT_THROW(eval("https://nixos.org"), Error);
}
TEST_F(TrivialExpressionTest, withFound) {