Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
@vcunat

This comment has been minimized.

Copy link
Owner Author

@vcunat vcunat commented Oct 28, 2016

Bug: this is affected by your ~/.nixpkgs/config.nix; I could find no switch or variable allowing me to disable that.

@vcunat

This comment has been minimized.

Copy link
Owner Author

@vcunat vcunat commented Oct 29, 2016

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).

@matthewbauer

This comment has been minimized.

Copy link

@matthewbauer matthewbauer commented Dec 14, 2016

@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