Skip to content

Instantly share code, notes, and snippets.

@HackerFoo
Last active July 22, 2020 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HackerFoo/686a6292eb49d09efdb02ae71b006c07 to your computer and use it in GitHub Desktop.
Save HackerFoo/686a6292eb49d09efdb02ae71b006c07 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Download from a Nix cache to a tarball
# --------------------------------------
# This script takes the part of the store path after /nix/store as the argument to specify what to download
# You can find this in the build details page on Hydra under "Output store paths".
# Requirements: nix, curl, xz (zxdec)
set -e
STORE_PATH=$1
TMPDIR=$(mktemp -d)
CACHE=https://hydra.vtr.tools
curl ${CACHE}/nar/${STORE_PATH} | xzdec | nix-store --restore ${TMPDIR}/${STORE_PATH}
tar -C ${TMPDIR} -czf ${PWD}/${STORE_PATH}.tar.gz ${STORE_PATH}
rm -rf ${TMPDIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment