@cryptotaxi247 / infra / commits / e550e0c6

nixos-channels-scripts: download zstd flavored nixexprs tarballs

Martin Weinelt committed Jul 8, 2026 at 18:03 UTC e550e0c65794725dd9a32ff94a5ff0f6b22b8177
2 files changed +68 -7
pkgs/nixos-channel-scripts/default.nix
+2
@@ -13,6 +13,7 @@
13 nix,
14 gnutar,
15 xz,
16 + zstd,
17 rsync,
18 openssh,
19 nix-index,
@@ -76,6 +77,7 @@ stdenv.mkDerivation {
77 nix
78 gnutar
79 xz
80 + zstd
81 rsync
82 openssh
83 nix-index
pkgs/nixos-channel-scripts/mirror-nixos-branch.pl
+66 -7
@@ -229,6 +229,7 @@ if ($bucketReleases && $bucketReleases->head_key("$releasePrefix")) {
229
230 if ($channelName =~ /nixos/) {
231 downloadFile("nixos.channel", "nixexprs.tar.xz", "source-dist", '\.tar\.xz$');
232 + downloadFile("nixos.channel", "nixexprs.tar.zst", "source-dist", '\.tar\.zst$');
233 downloadFile("nixpkgs.tarball", "packages.json.br", "json-br");
234 downloadFile("nixos.options", "options.json.br", "json-br");
235
@@ -269,22 +270,79 @@ if ($bucketReleases && $bucketReleases->head_key("$releasePrefix")) {
270
271 } else {
272 downloadFile("tarball", "nixexprs.tar.xz", "source-dist", '\.tar\.xz$');
273 + downloadFile("tarball", "nixexprs.tar.zst", "source-dist", '\.tar\.zst$');
274 downloadFile("tarball", "packages.json.br", "json-br");
275 }
276
277 # Generate the programs.sqlite database and put it in
276 - # nixexprs.tar.xz. Also maintain the debug info repository at
278 + # nixexprs.tar.{xz,zst}. Also maintain the debug info repository at
279 # https://cache.nixos.org/debuginfo.
280 if ($channelName =~ /nixos/ && -e "$tmpDir/store-paths") {
281 + # Unpack nixpkgs from tarball.
282 File::Path::make_path("$tmpDir/unpack");
280 - run("tar", "xfJ", "$tmpDir/nixexprs.tar.xz", "-C", "$tmpDir/unpack");
283 + run("tar",
284 + "--extract",
285 + "--file", "$tmpDir/nixexprs.tar.zst",
286 + "--zstd",
287 + "--directory", "$tmpDir/unpack"
288 + );
289 my $exprDir = glob("$tmpDir/unpack/*");
282 - run("nix-channel-index", "-o", "$exprDir/programs.sqlite", "-d", "$exprDir/debug.sqlite", "-f", "$exprDir/nixpkgs", "-s", "aarch64-linux", "-s", "x86_64-linux");
290 +
291 + # Create artifacts.
292 + run("nix-channel-index",
293 + "--output", "$exprDir/programs.sqlite",
294 + "--debug-output", "$exprDir/debug.sqlite",
295 + "--nixpkgs", "$exprDir/nixpkgs",
296 + "--platform", "aarch64-linux",
297 + "--platform", "x86_64-linux"
298 + );
299 +
300 run("index-debuginfo", "$exprDir/debug.sqlite", "s3://nix-cache");
284 - run("rm", "-f", "$tmpDir/nixexprs.tar.xz", "$exprDir/debug.sqlite");
285 - unlink("$tmpDir/nixexprs.tar.xz.sha256");
286 - run("tar", "cfJ", "$tmpDir/nixexprs.tar.xz", "-C", "$tmpDir/unpack", basename($exprDir));
287 - run("rm", "-rf", "$tmpDir/unpack");
301 +
302 + # Remove the downloaded tarballs and intermediate artifacts before repacking.
303 + run("rm",
304 + "--force",
305 + "$tmpDir/nixexprs.tar.xz",
306 + "$tmpDir/nixexprs.tar.xz.sha256",
307 + "$tmpDir/nixexprs.tar.zst",
308 + "$tmpDir/nixexprs.tar.zst.sha256",
309 + "$exprDir/debug.sqlite"
310 + );
311 +
312 + # Repack tarballs with the generated artifacts.
313 + run("tar",
314 + "--create",
315 + "--file=$tmpDir/nixexprs.tar.xz",
316 + "--xz",
317 + "--format=gnu",
318 + "--sort=name",
319 + "--owner=0",
320 + "--group=0",
321 + "--mtime=@315532800", # matches SOURCE_DATE_EPOCH from stdenv
322 + "--numeric-owner",
323 + "--directory=$tmpDir/unpack",
324 + basename($exprDir)
325 + );
326 + run("tar",
327 + "--create",
328 + "--file=$tmpDir/nixexprs.tar.zst",
329 + "--use-compress-program=zstd -19 -T0",
330 + "--format=gnu",
331 + "--sort=name",
332 + "--owner=0",
333 + "--group=0",
334 + "--mtime=@315532800", # matches SOURCE_DATE_EPOCH from stdenv
335 + "--numeric-owner",
336 + "--directory=$tmpDir/unpack",
337 + basename($exprDir)
338 + );
339 +
340 + # Clean up.
341 + run("rm",
342 + "--recursive",
343 + "--force",
344 + "$tmpDir/unpack"
345 + );
346 }
347
348 if (-e "$tmpDir/store-paths") {
@@ -376,6 +434,7 @@ sub redirect {
434 # Update channels on channels.nixos.org.
435 redirect($channelName, $releasePrefix);
436 redirect("$channelName/nixexprs.tar.xz", "$releasePrefix/nixexprs.tar.xz?rev=$rev&lastModified=$revUnix");
437 +redirect("$channelName/nixexprs.tar.zst", "$releasePrefix/nixexprs.tar.zst?rev=$rev&lastModified=$revUnix");
438 redirect("$channelName/git-revision", "$releasePrefix/git-revision");
439 redirect("$channelName/packages.json.br", "$releasePrefix/packages.json.br");
440 redirect("$channelName/store-paths.xz", "$releasePrefix/store-paths.xz");