mirror-nixos-branch: fetch channel artifacts from S3 directly (#68)

The channel scripts hit into NixOS/nixos-org-configurations#212
sometimes when fetching ISOs from cache.nixos.org to copy to the
channels bucket. This makes runs take hours when they should take
minutes.

There is no benefit gained from going through cache.nixos.org for this
use case. As noticed by @K900, the .iso nar.xz files on the cache are
unlikely to be touched by anyone other than the channel scripts, so we
don't even end up pre-warming the cache or anything along those lines -
if anything, we just waste cache bytes that could be used by other
paths.

Fixes #67.
This commit is contained in:
Pierre Bourdon 2024-01-28 19:40:32 +01:00 committed by GitHub
parent 074f417efa
commit 919045560c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -194,7 +194,7 @@ if ($bucketReleases && $bucketReleases->head_key("$releasePrefix")) {
if (! -e $dstFile) {
print STDERR "downloading $srcFile to $dstFile...\n";
write_file("$dstFile.sha256", "$sha256_expected $dstName");
runAllowFailure("NIX_REMOTE=https://cache.nixos.org/ nix --experimental-features nix-command store cat '$srcFile' > '$dstFile.tmp'") == 0
runAllowFailure("NIX_REMOTE=s3://nix-cache nix --experimental-features nix-command store cat '$srcFile' > '$dstFile.tmp'") == 0
or die "unable to fetch $srcFile\n";
rename("$dstFile.tmp", $dstFile) or die;
}