@@ -342,16 +342,25 @@ sub fetch {
342
342
my $cache_control = " maxage=600,stale-while-revalidate=1800,public" ;
343
343
344
344
sub redirect {
345
- my ($from , $to ) = @_ ;
345
+ my ($from , $to , $immutable_flake_tarball ) = @_ ;
346
346
$to = " https://releases.nixos.org/" . $to ;
347
347
print STDERR " redirect $from -> $to \n " ;
348
- $bucketChannels -> add_key($from , " " , { " x-amz-website-redirect-location" => $to , " cache-control" => $cache_control })
348
+ my $object_metadata = { " x-amz-website-redirect-location" => $to , " cache-control" => $cache_control };
349
+ if ($immutable_flake_tarball // 0) {
350
+ # Optionally sets a header for the "Lockable HTTP Tarball Protocol".
351
+ # See <https://github.com/NixOS/nix/blob/61f49de7ae0b3899abdcc102832523153dd40d35/doc/manual/source/protocols/tarball-fetcher.md>.
352
+ # AWS S3 does not not allow setting the "Link" header directly.
353
+ # Instead, we prefix the header with "x-amz-meta" and let Fastly
354
+ # rename the header for us.
355
+ $object_metadata -> {' x-amz-meta-link' } = " <$to ?rev=$rev >; rel=\" immutable\" " ;
356
+ }
357
+ $bucketChannels -> add_key($from , " " , $object_metadata )
349
358
or die $bucketChannels -> err . " : " . $bucketChannels -> errstr;
350
359
}
351
360
352
361
# Update channels on channels.nixos.org.
353
362
redirect($channelName , $releasePrefix );
354
- redirect(" $channelName /nixexprs.tar.xz" , " $releasePrefix /nixexprs.tar.xz" );
363
+ redirect(" $channelName /nixexprs.tar.xz" , " $releasePrefix /nixexprs.tar.xz" , 1 );
355
364
redirect(" $channelName /git-revision" , " $releasePrefix /git-revision" );
356
365
redirect(" $channelName /packages.json.br" , " $releasePrefix /packages.json.br" );
357
366
redirect(" $channelName /store-paths.xz" , " $releasePrefix /store-paths.xz" );
0 commit comments