nixos-rebuild: inline get-version-suffix script
It has no other consumers anyway. Also saves some work.
This commit is contained in:
parent
7df54fcf63
commit
1bf0ffb22e
@ -1,23 +0,0 @@
|
||||
getVersion() {
|
||||
local dir="$1"
|
||||
rev=
|
||||
gitDir="$dir/.git"
|
||||
if [ -e "$gitDir" ]; 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 --git-dir="$gitDir" rev-parse --short HEAD)
|
||||
if git --git-dir="$gitDir" 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
|
@ -548,6 +548,26 @@ getNixDrv() {
|
||||
fi
|
||||
}
|
||||
|
||||
getVersion() {
|
||||
local dir="$1"
|
||||
local rev=
|
||||
local gitDir="$dir/.git"
|
||||
if [ -e "$gitDir" ]; 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 --git-dir="$gitDir" rev-parse --short HEAD)
|
||||
if git --git-dir="$gitDir" describe --always --dirty | grep -q dirty; then
|
||||
rev+=M
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ".git.$rev"
|
||||
}
|
||||
|
||||
|
||||
if [[ -n $buildNix && -z $flake ]]; then
|
||||
log "building Nix..."
|
||||
getNixDrv
|
||||
@ -569,7 +589,7 @@ fi
|
||||
# nixos-version shows something useful).
|
||||
if [[ -n $canRun && -z $flake ]]; then
|
||||
if nixpkgs=$(runCmd nix-instantiate --find-file nixpkgs "${extraBuildFlags[@]}"); then
|
||||
suffix=$(runCmd $SHELL "$nixpkgs/nixos/modules/installer/tools/get-version-suffix" "${extraBuildFlags[@]}" || true)
|
||||
suffix=$(getVersion "$nixpkgs" || true)
|
||||
if [ -n "$suffix" ]; then
|
||||
echo -n "$suffix" > "$nixpkgs/.version-suffix" || true
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user