7 @coreutils@
/bin
/cat << EOF
8 Usage: uname [OPTION]...
9 Print certain system information. With no OPTION, same as -s.
11 -a, --all print all information, in the following order,
12 except omit -p and -i if unknown:
13 -s, --kernel-name print the kernel name
14 -n, --nodename print the network node hostname
15 -r, --kernel-release print the kernel release
16 -v, --kernel-version print the kernel version
17 -m, --machine print the machine hardware name
18 -p, --processor print the processor type (non-portable)
19 -i, --hardware-platform print the hardware platform (non-portable)
20 -o, --operating-system print the operating system
21 --help display this help and exit
22 --version output version information and exit
27 # Potential command-line options.
41 # With no OPTION, same as -s.
42 if [[ $# -eq 0 ]]; then
46 @getopt@
/bin
/getopt
--test > /dev
/null
&& rc
=$? || rc
=$?
47 if [[ $rc -ne 4 ]]; then
48 # This shouldn't happen.
49 echo "Warning: Enhanced getopt not supported, please open an issue in nixpkgs." >&2
51 # Define all short and long options.
53 LONG
=help,version
,kernel-name
,nodename
,kernel-release
,kernel-version
,machine
,processor
,hardware-platform
,operating-system
,all
56 PARSED
=`@getopt@/bin/getopt --options $SHORT --longoptions $LONG --name "$0" -- "$@"`
61 # Process each argument, and set the appropriate flag if we recognize it.
62 while [[ $# -ge 1 ]]; do
85 -i|
--hardware-platform)
88 -o|
--operating-system)
102 echo "uname: unrecognized option '$1'"
103 echo "Type 'uname --help' for a list of available options."
111 KERNEL_NAME_VAL
=@uSystem@
113 KERNEL_RELEASE_VAL
=@modDirVersion@
114 # #1-NixOS SMP PREEMPT_DYNAMIC Wed Dec 14 10:41:06 UTC 2022
115 KERNEL_VERSION_VAL
="#1-NixOS Tue Jan 1 00:00:00 UTC 1980"
116 MACHINE_VAL
=@processor@
117 PROCESSOR_VAL
=unknown
118 HARDWARE_PLATFORM_VAL
=unknown
119 OPERATING_SYSTEM_VAL
=@operatingSystem@
122 if [[ "$version" = "1" ]]; then
123 # in case some script greps for GNU coreutils.
124 echo "uname (GNU coreutils) 9.1"
125 echo "Nixpkgs deterministic-uname"
129 # output of the real uname from GNU coreutils
131 # Darwin *nodename* 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103 arm64 arm Darwin
133 # Linux *nodename* 6.0.13 #1-NixOS SMP PREEMPT_DYNAMIC Wed Dec 14 10:41:06 UTC 2022 x86_64 GNU/Linux
135 # FreeBSD *nodename* 14.0-RELEASE FreeBSD 14.0-RELEASE #0 releng/14.0-n265380-f9716eee8ab4: Fri Nov 10 05:57:23 UTC 2023 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 amd64 AMD Ryzen 9 5950X 16-Core Processor FreeBSD
137 if [[ "$all" = "1" ]]; then
138 output
+=("$KERNEL_NAME_VAL" "$NODENAME_VAL" "$KERNEL_RELEASE_VAL" "$KERNEL_VERSION_VAL" "$MACHINE_VAL")
139 # in help: except omit -p and -i if unknown.
140 # output+=($PROCESSOR_VAL $HARDWARE_PLATFORM_VAL)
141 output
+=("$OPERATING_SYSTEM_VAL")
144 if [[ "$kernel_name" = "1" ]]; then
145 output
+=("$KERNEL_NAME_VAL")
148 if [[ "$nodename" = "1" ]]; then
149 output
+=("$NODENAME_VAL")
152 if [[ "$kernel_release" = "1" ]]; then
153 output
+=("$KERNEL_RELEASE_VAL")
156 if [[ "$kernel_version" = "1" ]]; then
157 output
+=("$KERNEL_VERSION_VAL")
160 if [[ "$machine" = "1" ]]; then
161 output
+=("$MACHINE_VAL")
164 if [[ "$processor" = "1" ]]; then
165 output
+=("$PROCESSOR_VAL")
168 if [[ "$hardware_platform" = "1" ]]; then
169 output
+=("$HARDWARE_PLATFORM_VAL")
172 if [[ "$operating_system" = "1" ]]; then
173 output
+=("$OPERATING_SYSTEM_VAL")