Skip to content

Instantly share code, notes, and snippets.

@simonmichael
Last active December 4, 2019 11:39
Show Gist options
  • Save simonmichael/497a52ceb77bb52c4b47cf39f3a17109 to your computer and use it in GitHub Desktop.
Save simonmichael/497a52ceb77bb52c4b47cf39f3a17109 to your computer and use it in GitHub Desktop.
scripts for finding available versions in nixpkgs
# Some nixpkgs query scripts inspired by #nixos chat.
# Goal: find the HASH that will let an install command like
# nix-env -i -f https://github.com/NixOS/nixpkgs/archive/HASH.tar.gz -A hledger hledger-web hledger-ui
# install the latest available build of the packages, on all platforms of interest.
# These scripts don't seem to quite do that but they help.
NIXARCHS="darwin linux"
HLEDGERPKGS="hledger hledger-ui hledger-web"
# show help for the following commands
function nix-latest-help()
{
grep -E '^# nix-latest' ~/.bashrc.local # <- this file
}
# show nixpkgs latest successful build id on the given architecture for PKG
# nix-latest-build-on (linux|darwin) PKG
function nix-latest-build-on()
{
curl -sLH "accept: application/json" https://hydra.nixos.org/job/nixpkgs/trunk/"$2".x86_64-"$1"/latest | jq .id
}
# show nixpkgs latest successful build ids on all architectures for PKG
# nix-latest-build PKG
function nix-latest-builds()
{
for ARCH in $NIXARCHS; do
printf "latest build of %-11s on %-6s: $(nix-latest-build-on $ARCH $1)\n" $1 $ARCH
done
}
# show nixpkgs latest successful build ids on all architectures for the main hledger packages
# nix-latest-builds-hledger
function nix-latest-builds-hledger()
{
for PKG in $HLEDGERPKGS; do
nix-latest-builds $PKG
done
}
# show nixpkgs latest successful build urls on all architectures for PKG
# nix-latest-build-url PKG
function nix-latest-build-urls()
{
for ARCH in $NIXARCHS; do
printf "latest build of %-11s on %-6s: https://hydra.nixos.org/build/$(nix-latest-build-on $ARCH $1)\n" $1 $ARCH
done
}
# show nixpkgs latest successful build ids on all architectures for the main hledger packages
# nix-latest-build-urls-hledger
function nix-latest-build-urls-hledger()
{
for PKG in $HLEDGERPKGS; do
nix-latest-build-urls $PKG
done
}
# show nixpkgs github archive hash for latest successful build on the given architecture of PKG
# nix-latest-archive-on (linux|darwin) PKG
function nix-latest-archive-on()
{
BUILD=$(nix-latest-build-on $1 $2)
curl -sL https://hydra.nixos.org/build/$BUILD | grep -E '<td>........................................</td>' | cut -c 15-20
}
# show nixpkgs github archive hashes for the latest successful builds on all architectures of PKG
# nix-latest-archives PKG
function nix-latest-archives()
{
for ARCH in $NIXARCHS; do
printf "latest archive containing %-11s on %-6s: $(nix-latest-archive-on $ARCH $1)\n" $1 $ARCH
done
}
# show nixpkgs github archive hashes for the latest successful builds on all architectures of the main hledger packages
# nix-latest-archives-hledger
function nix-latest-archives-hledger()
{
for PKG in $HLEDGERPKGS; do
nix-latest-archives $PKG
done
}
# evaluations containing a build: https://hydra.nixos.org/build/99757008/evals
# hledger jobs within an evaluation:
# https://hydra.nixos.org/eval/EVAL?filter=hledger&compare=PREVEVAL
# succeeded: https://hydra.nixos.org/eval/1540383?filter=hledger&compare=1540357
# queued: https://hydra.nixos.org/eval/1540383?filter=hledger&compare=1540357&full=#tabs-unfinished
# archive rev: https://hydra.nixos.org/eval/1540383?filter=hledger&compare=1540357&full=#tabs-inputs -> Revision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment