Skip to content

Commit 30efa0a

Browse files
committed
mirror-nixos-branch: also expose date of commit
This is both very useful when viewing the summary html page on releases.nixos.org (via channels.nixos.org) and also makes it so when using the nixexprs.tar.xz as flake input, the flake metadata shows the same date as the equivalent github:NixOS/nixpkgs would yield, instead of relying on whatever the newest lastMod of any file in the tarball is.
1 parent 57cd021 commit 30efa0a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mirror-nixos-branch.pl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ sub fetch {
107107

108108
my $rev = $evalInfo->{jobsetevalinputs}->{nixpkgs}->{revision} or die;
109109

110+
# Get commit date of $rev as unixtime and formatted string
111+
my $revUnix = `git show --no-patch --format='%ct' $rev` or die;
112+
my $revDate = strftime("%F %T", localtime($revUnix));
113+
110114
print STDERR "\nRelease information:\n";
111-
print STDERR " - release is: $releaseName (build $releaseId)\n - eval is: $evalId\n - prefix is: $releasePrefix\n - Git commit is: $rev\n\n";
115+
print STDERR " - release is: $releaseName (build $releaseId)\n - eval is: $evalId\n - prefix is: $releasePrefix\n - Git commit is: $rev\n - Git commit date is: $revDate\n\n";
112116

113117
if ($bucketChannels) {
114118
# Guard against the channel going back in time.
@@ -280,7 +284,7 @@ sub fetch {
280284
my $html = "<html><head>";
281285
$html .= "<title>$title</title></head>";
282286
$html .= "<body><h1>$title</h1>";
283-
$html .= "<p>Released on $now from <a href='$githubLink'>Git commit <tt>$rev</tt></a> ";
287+
$html .= "<p>Released on $now from <a href='$githubLink'>Git commit <tt>$rev</tt></a> from $revDate ";
284288
$html .= "via <a href='$evalUrl'>Hydra evaluation $evalId</a>.</p>";
285289
$html .= "<table><thead><tr><th>File name</th><th>Size</th><th>SHA-256 hash</th></tr></thead><tbody>";
286290

@@ -357,7 +361,7 @@ sub redirect {
357361

358362
# Update channels on channels.nixos.org.
359363
redirect($channelName, $releasePrefix);
360-
redirect("$channelName/nixexprs.tar.xz", "$releasePrefix/nixexprs.tar.xz?rev=$rev");
364+
redirect("$channelName/nixexprs.tar.xz", "$releasePrefix/nixexprs.tar.xz?rev=$rev&lastModified=$revUnix");
361365
redirect("$channelName/git-revision", "$releasePrefix/git-revision");
362366
redirect("$channelName/packages.json.br", "$releasePrefix/packages.json.br");
363367
redirect("$channelName/store-paths.xz", "$releasePrefix/store-paths.xz");

0 commit comments

Comments
 (0)