summary refs log tree commit diff
path: root/lib/systems/platforms.nix
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2020-12-02 11:17:41 -0500
committerGitHub <noreply@github.com>2020-12-02 11:17:41 -0500
commit8e21ce5faeda18a82f84ce4ee812ce3a1a81b399 (patch)
tree62b18c56d1d61e34db23edb8328af1ce50453ef8 /lib/systems/platforms.nix
parent68fa053f4697914bb1e7d9118484a39c650fd66b (diff)
parent9918ba2dbaf2d6533baa53330a9ef9c32cfbf8a5 (diff)
downloadnixpkgs-8e21ce5faeda18a82f84ce4ee812ce3a1a81b399.tar
nixpkgs-8e21ce5faeda18a82f84ce4ee812ce3a1a81b399.tar.gz
nixpkgs-8e21ce5faeda18a82f84ce4ee812ce3a1a81b399.tar.bz2
nixpkgs-8e21ce5faeda18a82f84ce4ee812ce3a1a81b399.tar.lz
nixpkgs-8e21ce5faeda18a82f84ce4ee812ce3a1a81b399.tar.xz
nixpkgs-8e21ce5faeda18a82f84ce4ee812ce3a1a81b399.tar.zst
nixpkgs-8e21ce5faeda18a82f84ce4ee812ce3a1a81b399.zip
Merge pull request #105294 from Ericson2314/platform-config-improvements
Platform config improvements
Diffstat (limited to 'lib/systems/platforms.nix')
-rw-r--r--lib/systems/platforms.nix34
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix
index 7097e147966..a0dccc85988 100644
--- a/lib/systems/platforms.nix
+++ b/lib/systems/platforms.nix
@@ -471,10 +471,9 @@ rec {
   ## Other
   ##
 
-  riscv-multiplatform = bits: {
+  riscv-multiplatform = {
     name = "riscv-multiplatform";
     kernelArch = "riscv";
-    bfdEmulation = "elf${bits}lriscv";
     kernelTarget = "vmlinux";
     kernelAutoModules = true;
     kernelBaseConfig = "defconfig";
@@ -484,17 +483,22 @@ rec {
     '';
   };
 
-  selectBySystem = system: {
-      i486-linux = pc32;
-      i586-linux = pc32;
-      i686-linux = pc32;
-      x86_64-linux = pc64;
-      armv5tel-linux = sheevaplug;
-      armv6l-linux = raspberrypi;
-      armv7a-linux = armv7l-hf-multiplatform;
-      armv7l-linux = armv7l-hf-multiplatform;
-      aarch64-linux = aarch64-multiplatform;
-      mipsel-linux = fuloong2f_n32;
-      powerpc64le-linux = powernv;
-    }.${system} or pcBase;
+  select = platform:
+    # x86
+    /**/ if platform.isx86_32 then pc32
+    else if platform.isx86_64 then pc64
+
+    # ARM
+    else if platform.isAarch32 then let
+      version = platform.parsed.cpu.version or "";
+      in     if lib.versionOlder version "6" then sheevaplug
+        else if lib.versionOlder version "7" then raspberrypi
+        else armv7l-hf-multiplatform
+    else if platform.isAarch64 then aarch64-multiplatform
+
+    else if platform.parsed.cpu == lib.systems.parse.cpuTypes.mipsel then fuloong2f_n32
+
+    else if platform.parsed.cpu == lib.systems.parse.cpuTypes.powerpc64le then powernv
+
+    else pcBase;
 }