From b077f0d1170ea5eb76161f1da405a20c9ab556a5 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 7 Mar 2026 16:21:29 -0800 Subject: [PATCH] fetchtorrent: test single-file torrents --- .editorconfig | 2 +- .gitattributes | 3 +++ .../fetchtorrent/test-single-file.torrent | 1 + pkgs/build-support/fetchtorrent/tests.nix | 18 +++++++++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 pkgs/build-support/fetchtorrent/test-single-file.torrent diff --git a/.editorconfig b/.editorconfig index 3a2159d33734..873d7efb1372 100644 --- a/.editorconfig +++ b/.editorconfig @@ -79,7 +79,7 @@ indent_size = unset trim_trailing_whitespace = true # binaries -[*.nib] +[*.{nib,torrent}] end_of_line = unset insert_final_newline = unset trim_trailing_whitespace = unset diff --git a/.gitattributes b/.gitattributes index d67974e66b69..2c113f5fd5dc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -62,3 +62,6 @@ ci/OWNERS linguist-language=CODEOWNERS # patching CRLF line endings from an upstream source package. *.diff !text !eol *.patch !text !eol + +# Torrent files are binary files and should not be re-encoded. +*.torrent !text !eol diff --git a/pkgs/build-support/fetchtorrent/test-single-file.torrent b/pkgs/build-support/fetchtorrent/test-single-file.torrent new file mode 100644 index 000000000000..0d8ecae342d7 --- /dev/null +++ b/pkgs/build-support/fetchtorrent/test-single-file.torrent @@ -0,0 +1 @@ +d10:created by13:mktorrent 1.113:creation datei1772926249e4:infod6:lengthi1097e4:name7:COPYING12:piece lengthi262144e6:pieces20:€åÏÊ\c™èçæÉ\Q3Ní-e8:url-list96:https://raw.githubusercontent.com/NixOS/nixpkgs/3d82431ec4b51262989559b821b83abe4a9f6dbd/COPYINGe \ No newline at end of file diff --git a/pkgs/build-support/fetchtorrent/tests.nix b/pkgs/build-support/fetchtorrent/tests.nix index c4f61aa30ad9..ef14999254ff 100644 --- a/pkgs/build-support/fetchtorrent/tests.nix +++ b/pkgs/build-support/fetchtorrent/tests.nix @@ -75,7 +75,7 @@ let ); in # Seems almost but not quite worth using lib.mapCartesianProduct... -builtins.mapAttrs (n: v: testers.invalidateFetcherByDrvHash fetchtorrentWithHash v) { +(builtins.mapAttrs (n: v: testers.invalidateFetcherByDrvHash fetchtorrentWithHash v) { http-link = { inherit (http) url; inherit (flattened) postFetch; @@ -140,4 +140,20 @@ builtins.mapAttrs (n: v: testers.invalidateFetcherByDrvHash fetchtorrentWithHash # flatten = false; # inherit (unflattened) postFetch; #}; +}) +// { + # Make sure we can download and "flatten" single-file torrents. + # We only test with transmission because we use a web-seed and rqbit + # doesn't support web-seeds. + single-file = fetchtorrent { + hash = "sha256-u5c/ZN5V79Jg1aN6spbui4OdhExsXjofk1JpvUdW7Ro="; + backend = "transmission"; + flatten = true; + url = "${./test-single-file.torrent}"; + meta = { + hydraPlatforms = [ ]; + license = lib.licenses.mit; + description = "The license file for the Nixpkgs repository as of 7 March 2026"; + }; + }; }