Skip to content

Commit

Permalink
Merge pull request #8463 from edolstra/release-artifacts
Browse files Browse the repository at this point in the history
Upload manual + fallback-paths.nix in the release script
  • Loading branch information
edolstra authored Jun 6, 2023
2 parents 2b01e83 + 76e032b commit bf7dc3c
Showing 1 changed file with 44 additions and 20 deletions.
64 changes: 44 additions & 20 deletions maintainers/upload-release.pl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,38 @@ sub fetch {

my $channelsBucket = $s3_us->bucket($channelsBucketName) or die;

sub getStorePath {
my ($jobName, $output) = @_;
my $buildInfo = decode_json(fetch("$evalUrl/job/$jobName", 'application/json'));
return $buildInfo->{buildoutputs}->{$output or "out"}->{path} or die "cannot get store path for '$jobName'";
}

sub copyManual {
my $manual = getStorePath("build.x86_64-linux", "doc");
print "$manual\n";

my $manualNar = "$tmpDir/$releaseName-manual.nar.xz";
print "$manualNar\n";

unless (-e $manualNar) {
system("NIX_REMOTE=$binaryCache nix store dump-path '$manual' | xz > '$manualNar'.tmp") == 0
or die "unable to fetch $manual\n";
rename("$manualNar.tmp", $manualNar) or die;
}

unless (-e "$tmpDir/manual") {
system("xz -d < '$manualNar' | nix-store --restore $tmpDir/manual.tmp") == 0
or die "unable to unpack $manualNar\n";
rename("$tmpDir/manual.tmp/share/doc/nix/manual", "$tmpDir/manual") or die;
system("rm -rf '$tmpDir/manual.tmp'") == 0 or die;
}

system("aws s3 sync '$tmpDir/manual' s3://$releasesBucketName/$releaseDir/manual") == 0
or die "syncing manual to S3\n";
}

copyManual;

sub downloadFile {
my ($jobName, $productNr, $dstName) = @_;

Expand Down Expand Up @@ -179,18 +211,28 @@ sub downloadFile {
system("docker manifest push nixos/nix:latest") == 0 or die;
}

# Upload nix-fallback-paths.nix.
write_file("$tmpDir/fallback-paths.nix",
"{\n" .
" x86_64-linux = \"" . getStorePath("build.x86_64-linux") . "\";\n" .
" i686-linux = \"" . getStorePath("build.i686-linux") . "\";\n" .
" aarch64-linux = \"" . getStorePath("build.aarch64-linux") . "\";\n" .
" x86_64-darwin = \"" . getStorePath("build.x86_64-darwin") . "\";\n" .
" aarch64-darwin = \"" . getStorePath("build.aarch64-darwin") . "\";\n" .
"}\n");

# Upload release files to S3.
for my $fn (glob "$tmpDir/*") {
my $name = basename($fn);
next if $name eq "manual";
my $dstKey = "$releaseDir/" . $name;
unless (defined $releasesBucket->head_key($dstKey)) {
print STDERR "uploading $fn to s3://$releasesBucketName/$dstKey...\n";

my $configuration = ();
$configuration->{content_type} = "application/octet-stream";

if ($fn =~ /.sha256|install/) {
# Text files
if ($fn =~ /.sha256|install|\.nix$/) {
$configuration->{content_type} = "text/plain";
}

Expand All @@ -199,24 +241,6 @@ sub downloadFile {
}
}

# Print new nix-fallback-paths.nix.
if ($isLatest) {
sub getStorePath {
my ($jobName) = @_;
my $buildInfo = decode_json(fetch("$evalUrl/job/$jobName", 'application/json'));
return $buildInfo->{buildoutputs}->{out}->{path} or die "cannot get store path for '$jobName'";
}

print STDERR "nixos/modules/installer/tools/nix-fallback-paths.nix:\n" .
"{\n" .
" x86_64-linux = \"" . getStorePath("build.x86_64-linux") . "\";\n" .
" i686-linux = \"" . getStorePath("build.i686-linux") . "\";\n" .
" aarch64-linux = \"" . getStorePath("build.aarch64-linux") . "\";\n" .
" x86_64-darwin = \"" . getStorePath("build.x86_64-darwin") . "\";\n" .
" aarch64-darwin = \"" . getStorePath("build.aarch64-darwin") . "\";\n" .
"}\n";
}

# Update the "latest" symlink.
$channelsBucket->add_key(
"nix-latest/install", "",
Expand Down

0 comments on commit bf7dc3c

Please sign in to comment.