diff options
Diffstat (limited to 'nixos/modules/installer/tools/nixos-version.sh')
-rw-r--r-- | nixos/modules/installer/tools/nixos-version.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/nixos/modules/installer/tools/nixos-version.sh b/nixos/modules/installer/tools/nixos-version.sh new file mode 100644 index 00000000000..59a9c572b41 --- /dev/null +++ b/nixos/modules/installer/tools/nixos-version.sh @@ -0,0 +1,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 |