fix nixos-version --hash when building from git

This commit is contained in:
Benno Fünfstück
2016-07-23 22:59:03 +02:00
parent d21727991b
commit 1e534e234b
2 changed files with 5 additions and 4 deletions
@@ -1,22 +0,0 @@
getVersion() {
local dir="$1"
rev=
if [ -e "$dir/.git" ]; then
if [ -z "$(type -P git)" ]; then
echo "warning: Git not found; cannot figure out revision of $dir" >&2
return
fi
cd "$dir"
rev=$(git rev-parse --short HEAD)
if git describe --always --dirty | grep -q dirty; then
rev+=M
fi
fi
}
if nixpkgs=$(nix-instantiate --find-file nixpkgs "$@"); then
getVersion $nixpkgs
if [ -n "$rev" ]; then
echo ".git.$rev"
fi
fi