From d8934feba1399d220550b81dceeb6da35149cf02 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 19 Apr 2019 14:51:25 -0400 Subject: [PATCH] kernel-headers: infer ARCH from config triple This makes us less reliant on the systems/examples.nix. You should be able to cross compile with just your triple: $ nix build --arg crossSystem '{ config = "armv6l-unknown-linux-gnueabi"; }' stdenv --- lib/systems/default.nix | 7 +++++++ pkgs/os-specific/linux/kernel-headers/default.nix | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 8eeab67f7f3..b45a5fd8d2b 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -72,6 +72,13 @@ rec { release = null; }; + kernelArch = + if final.isAarch32 then "arm" + else if final.isAarch64 then "arm64" + else if final.isx86_32 then "x86" + else if final.isx86_64 then "ia64" + else final.parsed.cpu.name; + qemuArch = if final.isArm then "arm" else if final.isx86_64 then "x86_64" diff --git a/pkgs/os-specific/linux/kernel-headers/default.nix b/pkgs/os-specific/linux/kernel-headers/default.nix index c00fc1761d5..ea4e041d43a 100644 --- a/pkgs/os-specific/linux/kernel-headers/default.nix +++ b/pkgs/os-specific/linux/kernel-headers/default.nix @@ -12,7 +12,7 @@ let inherit sha256; }; - ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or (throw "missing kernelArch"); + ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or stdenvNoCC.hostPlatform.kernelArch; # It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc. # We do this so we have a build->build, not build->host, C compiler.