diff --git a/nixos/modules/installer/tools/get-version-suffix b/nixos/modules/installer/tools/get-version-suffix deleted file mode 100644 index 8d72905cdcb4..000000000000 --- a/nixos/modules/installer/tools/get-version-suffix +++ /dev/null @@ -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 diff --git a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh index 957f03c5fc8e..023bdde5b90d 100755 --- a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh +++ b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh @@ -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