lib/systems: use lookup for uname.system

This is a little bit cleaner and avoids the if ... else if ... chain.
This commit is contained in:
Matthew Bauer 2018-10-17 14:43:49 -05:00
parent e3de8a9232
commit 45cc6e2a42

View file

@ -50,13 +50,14 @@ rec {
# Output from uname
uname = {
# uname -s
system = if final.isLinux then "Linux"
else if final.isDarwin then "Darwin"
else if final.isWindows then "Windows"
else if final.isFreeBSD then "FreeBSD"
else if final.isNetBSD then "NetBSD"
else if final.isOpenBSD then "OpenBSD"
else null;
system = {
"linux" = "Linux";
"windows" = "Windows";
"darwin" = "Darwin";
"netbsd" = "NetBSD";
"freebsd" = "FreeBSD";
"openbsd" = "OpenBSD";
}.${final.parsed.kernel.name} or null;
# uname -p
processor = final.parsed.cpu.name;