From 17a40e5195705316468fd795ec78b5ec38496911 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 25 Apr 2025 11:22:21 +0200 Subject: [PATCH 1/2] Warn about the use of channel URLs --- src/libexpr/eval-settings.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libexpr/eval-settings.cc b/src/libexpr/eval-settings.cc index 659c01a9e..85ec98816 100644 --- a/src/libexpr/eval-settings.cc +++ b/src/libexpr/eval-settings.cc @@ -84,9 +84,14 @@ bool EvalSettings::isPseudoUrl(std::string_view s) std::string EvalSettings::resolvePseudoUrl(std::string_view url) { - if (hasPrefix(url, "channel:")) + if (hasPrefix(url, "channel:")) { + static bool haveWarned = false; + warnOnce(haveWarned, + "Channels are deprecated in favor of flakes in Determinate Nix. " + "For a guide on Nix flakes, see: https://zero-to-nix.com/. " + "For details and to offer feedback on the deprecation process, see: https://github.com/DeterminateSystems/nix-src/issues/34."); return "https://nixos.org/channels/" + std::string(url.substr(8)) + "/nixexprs.tar.xz"; - else + } else return std::string(url); } @@ -103,4 +108,4 @@ Path getNixDefExpr() : getHome() + "/.nix-defexpr"; } -} // namespace nix \ No newline at end of file +} // namespace nix From 797c716f746fe1474600a5836042b598b8e6f20d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 25 Apr 2025 16:05:17 +0200 Subject: [PATCH 2/2] Suggest fix --- src/libexpr/eval-settings.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libexpr/eval-settings.cc b/src/libexpr/eval-settings.cc index 85ec98816..8fbe94aef 100644 --- a/src/libexpr/eval-settings.cc +++ b/src/libexpr/eval-settings.cc @@ -85,12 +85,15 @@ bool EvalSettings::isPseudoUrl(std::string_view s) std::string EvalSettings::resolvePseudoUrl(std::string_view url) { if (hasPrefix(url, "channel:")) { + auto realUrl = "https://nixos.org/channels/" + std::string(url.substr(8)) + "/nixexprs.tar.xz"; static bool haveWarned = false; warnOnce(haveWarned, "Channels are deprecated in favor of flakes in Determinate Nix. " + "Instead of '%s', use '%s'. " "For a guide on Nix flakes, see: https://zero-to-nix.com/. " - "For details and to offer feedback on the deprecation process, see: https://github.com/DeterminateSystems/nix-src/issues/34."); - return "https://nixos.org/channels/" + std::string(url.substr(8)) + "/nixexprs.tar.xz"; + "For details and to offer feedback on the deprecation process, see: https://github.com/DeterminateSystems/nix-src/issues/34.", + url, realUrl); + return realUrl; } else return std::string(url); }