Skip to content

Instantly share code, notes, and snippets.

@NickCao
Created July 23, 2022 04:55
Show Gist options
  • Save NickCao/3aff5ce68f6bbe683c7e28f9e8323873 to your computer and use it in GitHub Desktop.
Save NickCao/3aff5ce68f6bbe683c7e28f9e8323873 to your computer and use it in GitHub Desktop.
#! /usr/bin/env nix-shell
#! nix-shell -i perl -p perl perlPackages.LWPUserAgent perlPackages.LWPProtocolHttps
use strict;
use JSON::PP;
use LWP::UserAgent;
my $evalId = $ARGV[0] or die "Usage: $0 EVAL-ID\n";
sub fetch {
my ($url, $type) = @_;
my $ua = LWP::UserAgent->new;
$ua->default_header('Accept', $type) if defined $type;
my $response = $ua->get($url);
die "could not download $url: ", $response->status_line, "\n" unless $response->is_success;
return $response->decoded_content;
}
my $evalUrl = "https://hydra.nixos.org/eval/$evalId";
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("{\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");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment