This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ "$#" != 2 ]; then | |
echo "Usage: $0 commit-hash commit-hash" | |
echo -e "\tYou need to be in a git-controlled nixpkgs tree." | |
exit 1 | |
fi | |
echo "Estimating rebuild amount, by packages visible to nix-env:" | |
echo "(If you get 0, it's an evaluation error, most likely.)" | |
# Output packages in tree $2 that weren't in $1. | |
# Changing the output hash or name is taken as a change. | |
# Extra nix-env parameters can be in $3 | |
newPkgs() { | |
comm -13 \ | |
<(nix-env -f "$1" -qa --out-path --show-trace $3 | sort) \ | |
<(nix-env -f "$2" -qa --out-path --show-trace $3 | sort) | |
} | |
declare -a tree | |
for i in 1 2; do | |
tree[$i]="$(mktemp --tmpdir -d nix-rebuild-amount-XXXXXXXX)" | |
done | |
cleanup() { | |
rm -rf "${tree[1]}" "${tree[2]}" | |
} | |
trap cleanup EXIT SIGINT SIGQUIT ERR | |
for i in 1 2; do | |
git "--work-tree=${tree[$i]}" checkout "${!i}" "*" | |
done | |
for platform in x86_64-{linux,darwin}; do | |
newPkgs "${tree[1]}" "${tree[2]}" "--argstr system $platform" \ | |
2>/dev/null \ | |
| (wc -l; echo "^ $platform") & | |
done | |
wait | |
Beware: the current implementation can change the git index. A better way to checkout files should be found (I didn't want a full clone).
@vcunat You can set "config" as an arg to override ~/.nixpkgs/config.nix. For example:
nix-env -f "$2" -qa --out-path --show-trace $3 --arg config "{}"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug: this is affected by your
~/.nixpkgs/config.nix
; I could find no switch or variable allowing me to disable that.