summary refs log tree commit diff
path: root/nixos/modules/installer/tools/nixos-version.sh
blob: 59a9c572b41840b7b0c07393c7ed5b94d86fe6d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! @runtimeShell@
# shellcheck shell=bash

case "$1" in
  -h|--help)
    exec man nixos-version
    exit 1
    ;;
  --hash|--revision)
    if ! [[ @revision@ =~ ^[0-9a-f]+$ ]]; then
      echo "$0: Nixpkgs commit hash is unknown"
      exit 1
    fi
    echo "@revision@"
    ;;
  --json)
    cat <<EOF
@json@
EOF
    ;;
  *)
    echo "@version@ (@codeName@)"
    ;;
esac