1getVersion() { 2 local dir="$1" 3 rev= 4 if [ -e "$dir/.git" ]; then 5 if [ -z "$(type -P git)" ]; then 6 echo "warning: Git not found; cannot figure out revision of $dir" >&2 7 return 8 fi 9 cd "$dir" 10 rev=$(git rev-parse --short HEAD) 11 if git describe --always --dirty | grep -q dirty; then 12 rev+=M 13 fi 14 fi 15} 16 17if nixpkgs=$(nix-instantiate --find-file nixpkgs "$@"); then 18 getVersion $nixpkgs 19 if [ -n "$rev" ]; then 20 echo ".git.$rev" 21 fi 22fi