Skip to content

Instantly share code, notes, and snippets.

@basile-henry
Created November 21, 2020 15:43
Show Gist options
  • Save basile-henry/4f16a9ab675902b8e5507b38c990dba2 to your computer and use it in GitHub Desktop.
Save basile-henry/4f16a9ab675902b8e5507b38c990dba2 to your computer and use it in GitHub Desktop.
Quickly check if a derivation is reproducible
#! /usr/bin/env nix-shell
#! nix-shell -i bash --pure -p diffoscope nix
# shellcheck shell=bash
set -eo pipefail
if [[ -z "$1" ]]; then
cat <<EOF
usage:
./r13y.sh -A some.attribute
./r13y.sh /path/to/some.drv
EOF
exit 1
elif [[ "$1" == "-A" ]]; then
DERIV=$(nix-instantiate --quiet --quiet -A "$2")
else
DERIV="$1"
fi
echo "Building derivation \"$DERIV\"..."
nix-build "$DERIV"
echo "Checking derivation \"$DERIV\"..."
if ! OUT=$(nix-build "$DERIV" --check --keep-failed |& tail -1); then
A=$(cut -d ' ' -f9 <<< "$OUT")
B=$(cut -d ' ' -f12 <<< "$OUT")
diffoscope "${A//\'/}" "${B//\'/}"
fi
echo "Seems reproducible!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment