From 45cc6e2a4286276387d0bcb768a1e45086719210 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 17 Oct 2018 14:43:49 -0500 Subject: [PATCH] lib/systems: use lookup for uname.system This is a little bit cleaner and avoids the if ... else if ... chain. --- lib/systems/default.nix | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 6c6ce5c6ef6..8f5ef44ae72 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -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;