2020-04-24 23:36:52 +00:00
|
|
|
getVersion() {
|
|
|
|
local dir="$1"
|
|
|
|
rev=
|
2022-07-14 12:49:19 +00:00
|
|
|
gitDir="$dir/.git"
|
|
|
|
if [ -e "$gitDir" ]; then
|
2020-04-24 23:36:52 +00:00
|
|
|
if [ -z "$(type -P git)" ]; then
|
|
|
|
echo "warning: Git not found; cannot figure out revision of $dir" >&2
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
cd "$dir"
|
2022-07-14 12:49:19 +00:00
|
|
|
rev=$(git --git-dir="$gitDir" rev-parse --short HEAD)
|
|
|
|
if git --git-dir="$gitDir" describe --always --dirty | grep -q dirty; then
|
2020-04-24 23:36:52 +00:00
|
|
|
rev+=M
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if nixpkgs=$(nix-instantiate --find-file nixpkgs "$@"); then
|
|
|
|
getVersion $nixpkgs
|
|
|
|
if [ -n "$rev" ]; then
|
|
|
|
echo ".git.$rev"
|
|
|
|
fi
|
|
|
|
fi
|