From 613a98461fabecf819afef74155c9934c98456b2 Mon Sep 17 00:00:00 2001 From: Adam Dinwoodie Date: Sat, 9 Aug 2025 18:31:14 +0100 Subject: [PATCH] fetchtorrent: check JSON config usage correctly The arguments to `fetchtorrent` are supposed to throw an error if the user attempts to specify JSON configuration when they're not using the transmission backend, however a logic error means the error will never be thrown. Move the test to somewhere where the behaviour will actually be checked. --- pkgs/build-support/fetchtorrent/default.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/fetchtorrent/default.nix b/pkgs/build-support/fetchtorrent/default.nix index d281e71fe4ae..48c781d864f8 100644 --- a/pkgs/build-support/fetchtorrent/default.nix +++ b/pkgs/build-support/fetchtorrent/default.nix @@ -18,11 +18,7 @@ in "bittorrent" else "bittorrent-" + builtins.head (builtins.match urlRegexp url), - config ? - if (backend == "transmission") then - { } - else - throw "json config for configuring fetchFromBitorrent only works with the transmission backend", + config ? { }, hash, backend ? "transmission", recursiveHash ? true, @@ -44,6 +40,9 @@ let ''; jsonConfig = (formats.json { }).generate "jsonConfig" config; in +assert lib.assertMsg (config != { } -> backend == "transmission") '' + json config for configuring fetchtorrent only works with the transmission backend +''; runCommand name { inherit meta;