|
2 | 2 | lib, |
3 | 3 | testers, |
4 | 4 | fetchtorrent, |
| 5 | + emptyDirectory, |
5 | 6 | ... |
6 | 7 | }: |
7 | 8 |
|
8 | 9 | let |
| 10 | + # This meta attribute isn't used anywhere, as the actual derivation |
| 11 | + # realizations are only empty directories. It's maintained here as a record |
| 12 | + # of the details of the intermediate product that exists briefly while |
| 13 | + # building the test derivations. |
| 14 | + # |
| 15 | + # Ideally we'd use a smaller download, but neither of the Bittorrent backends |
| 16 | + # supported by fetchtorrent appear to support torrents that are only reliably |
| 17 | + # seeded by HTTP sources rather than other people using Bittorrent clients. |
| 18 | + # Sintel was the smallest torrent I could find that had a free license and |
| 19 | + # was reliably seeded by other Bittorrent clients. |
| 20 | + # |
| 21 | + # For more information, see the discussion at |
| 22 | + # https://github.com/NixOS/nixpkgs/pull/432091/files/bd13421b2b70f3f125061018c800439ef2d43e8d#r2264073113 |
9 | 23 | sintel.meta = { |
10 | 24 | description = "An open source short film to show off open source technologies."; |
11 | 25 | longDescription = '' |
12 | 26 | An independently produced short film, initiated by the Blender Foundation |
13 | | - as a means to further improve andvalidate the free/open source 3D |
| 27 | + as a means to further improve and validate the free/open source 3D |
14 | 28 | creation suite Blender. |
15 | 29 | ''; |
16 | 30 | license = lib.licenses.cc-by-30; |
17 | 31 | homepage = "https://durian.blender.org/"; |
18 | 32 | }; |
19 | 33 |
|
20 | 34 | # Via https://webtorrent.io/free-torrents |
21 | | - http.url = "https://webtorrent.io/torrents/sintel.torrent"; |
| 35 | + http.url = "${./test-sintel.torrent}"; |
22 | 36 | magnet.url = "magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent"; |
23 | 37 |
|
24 | | - flattened.hash = "sha256-EzbmBiTEWOlFUNaV5R4eDeD9EBbp6d93rfby88ACg0s="; |
25 | | - unflattened.hash = "sha256-lVrlo1AwmFcxwsIsY976VYqb3hAprFH1xWYdmlTuw0U="; |
| 38 | + # Sintel isn't a massive download, but it's not small. There's also no real |
| 39 | + # value in storing copies of it in Nix caches, which is what happens by |
| 40 | + # default when this test succeeds. Avoid that by verifying the downloaded |
| 41 | + # files using `sha512sum` in the post-fetch hook, then deleting the files so |
| 42 | + # the actual derivation result is an empty directory. |
| 43 | + # |
| 44 | + # Chain `&&` in the postFetch phase because the transmission backend does not |
| 45 | + # run that phase with `errexit` enabled. |
| 46 | + flattened.postFetch = '' |
| 47 | + pushd "$out" && |
| 48 | + sha512sum --check --strict ${./test-hashes.sha512sum} && |
| 49 | + sed 's/.* //' ${./test-hashes.sha512sum} | xargs rm --verbose && |
| 50 | + popd |
| 51 | + ''; |
| 52 | + unflattened.postFetch = '' |
| 53 | + pushd "$out" && |
| 54 | + pushd Sintel && |
| 55 | + sha512sum --check --strict ${./test-hashes.sha512sum} && |
| 56 | + sed 's/.* //' ${./test-hashes.sha512sum} | xargs rm --verbose && |
| 57 | + popd && |
| 58 | + rm --dir --verbose Sintel && |
| 59 | + popd |
| 60 | + ''; |
| 61 | + |
| 62 | + # Fixed output derivation hash is identical for all derivations: the empty |
| 63 | + # directory. |
| 64 | + fetchtorrentWithHash = |
| 65 | + args: |
| 66 | + fetchtorrent ( |
| 67 | + { |
| 68 | + hash = builtins.convertHash { |
| 69 | + hash = emptyDirectory.outputHash; |
| 70 | + toHashFormat = "sri"; |
| 71 | + hashAlgo = emptyDirectory.outputHashAlgo; |
| 72 | + }; |
| 73 | + } |
| 74 | + // args |
| 75 | + ); |
26 | 76 | in |
27 | 77 | # Seems almost but not quite worth using lib.mapCartesianProduct... |
28 | | -builtins.mapAttrs (n: v: testers.invalidateFetcherByDrvHash fetchtorrent v) { |
| 78 | +builtins.mapAttrs (n: v: testers.invalidateFetcherByDrvHash fetchtorrentWithHash v) { |
29 | 79 | http-link = { |
30 | 80 | inherit (http) url; |
31 | | - inherit (flattened) hash; |
32 | | - inherit (sintel) meta; |
| 81 | + inherit (flattened) postFetch; |
33 | 82 | }; |
34 | 83 | http-link-transmission = { |
35 | 84 | inherit (http) url; |
36 | 85 | backend = "transmission"; |
37 | | - inherit (flattened) hash; |
38 | | - inherit (sintel) meta; |
| 86 | + inherit (flattened) postFetch; |
39 | 87 | }; |
40 | 88 | magnet-link = { |
41 | 89 | inherit (magnet) url; |
42 | | - inherit (flattened) hash; |
43 | | - inherit (sintel) meta; |
| 90 | + inherit (flattened) postFetch; |
44 | 91 | }; |
45 | 92 | magnet-link-transmission = { |
46 | 93 | inherit (magnet) url; |
47 | 94 | backend = "transmission"; |
48 | | - inherit (flattened) hash; |
49 | | - inherit (sintel) meta; |
| 95 | + inherit (flattened) postFetch; |
50 | 96 | }; |
51 | 97 | http-link-rqbit = { |
52 | 98 | inherit (http) url; |
53 | 99 | backend = "rqbit"; |
54 | | - inherit (flattened) hash; |
55 | | - inherit (sintel) meta; |
| 100 | + inherit (flattened) postFetch; |
56 | 101 | }; |
57 | 102 | magnet-link-rqbit = { |
58 | 103 | inherit (magnet) url; |
59 | 104 | backend = "rqbit"; |
60 | | - inherit (flattened) hash; |
61 | | - inherit (sintel) meta; |
| 105 | + inherit (flattened) postFetch; |
62 | 106 | }; |
63 | 107 | http-link-rqbit-flattened = { |
64 | 108 | inherit (http) url; |
65 | 109 | backend = "rqbit"; |
66 | 110 | flatten = true; |
67 | | - inherit (flattened) hash; |
68 | | - inherit (sintel) meta; |
| 111 | + inherit (flattened) postFetch; |
69 | 112 | }; |
70 | 113 | magnet-link-rqbit-flattened = { |
71 | 114 | inherit (magnet) url; |
72 | 115 | backend = "rqbit"; |
73 | 116 | flatten = true; |
74 | | - inherit (flattened) hash; |
75 | | - inherit (sintel) meta; |
| 117 | + inherit (flattened) postFetch; |
76 | 118 | }; |
77 | 119 | http-link-rqbit-unflattened = { |
78 | 120 | inherit (http) url; |
79 | 121 | backend = "rqbit"; |
80 | 122 | flatten = false; |
81 | | - inherit (unflattened) hash; |
82 | | - inherit (sintel) meta; |
| 123 | + inherit (unflattened) postFetch; |
83 | 124 | }; |
84 | 125 | magnet-link-rqbit-unflattened = { |
85 | 126 | inherit (magnet) url; |
86 | 127 | backend = "rqbit"; |
87 | 128 | flatten = false; |
88 | | - inherit (unflattened) hash; |
89 | | - inherit (sintel) meta; |
| 129 | + inherit (unflattened) postFetch; |
90 | 130 | }; |
91 | 131 | } |
0 commit comments