summary refs log tree commit diff
path: root/lib/systems/default.nix
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2018-10-17 14:43:49 -0500
committerMatthew Bauer <mjbauer95@gmail.com>2018-10-17 14:43:49 -0500
commit45cc6e2a4286276387d0bcb768a1e45086719210 (patch)
tree72d580f09588e5f48637da91bdfcad8f5c0440fa /lib/systems/default.nix
parente3de8a92325620e65039d98281047a83fa07c9dd (diff)
downloadnixpkgs-45cc6e2a4286276387d0bcb768a1e45086719210.tar
nixpkgs-45cc6e2a4286276387d0bcb768a1e45086719210.tar.gz
nixpkgs-45cc6e2a4286276387d0bcb768a1e45086719210.tar.bz2
nixpkgs-45cc6e2a4286276387d0bcb768a1e45086719210.tar.lz
nixpkgs-45cc6e2a4286276387d0bcb768a1e45086719210.tar.xz
nixpkgs-45cc6e2a4286276387d0bcb768a1e45086719210.tar.zst
nixpkgs-45cc6e2a4286276387d0bcb768a1e45086719210.zip
lib/systems: use lookup for uname.system
This is a little bit cleaner and avoids the if ... else if ... chain.
Diffstat (limited to 'lib/systems/default.nix')
-rw-r--r--lib/systems/default.nix15
1 files 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;