Files
nixpkgs/nixos/modules/installer/tools/nixos-version.sh

47 lines
950 B
Bash

#! @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" >&2
exit 1
fi
echo "@revision@"
;;
--configuration-revision)
if [[ "@configurationRevision@" =~ "@" ]]; then
echo "$0: configuration revision is unknown" >&2
exit 1
fi
echo "@configurationRevision@"
;;
--kernel-version)
if [[ "@kernelVersion@" =~ "@" ]]; then
echo "$0: kernel version is unknown" >&2
exit 1
fi
echo "@kernelVersion@"
;;
--specialisations)
specialisations=@specialisations@
if [[ -z "$specialisations" ]]; then
echo "$0: no specialisations found" >&2
exit 1
fi
printf '%s\n' "$specialisations"
;;
--json)
cat <<'EOF'
@json@
EOF
;;
*)
echo "@version@ (@codeName@)"
;;
esac