diff --git a/devices/motorola-addison/kernel/default.nix b/devices/motorola-addison/kernel/default.nix index 7fe18896..832af422 100644 --- a/devices/motorola-addison/kernel/default.nix +++ b/devices/motorola-addison/kernel/default.nix @@ -13,7 +13,7 @@ # This is because motorola ships an armv7l userspace from stock ROM. # # in local.nix: -# mobile.system.platform = lib.mkForce "armv7a-linux"; +# mobile.system.system = lib.mkForce "armv7l-linux"; # let diff --git a/modules/hardware-generic.nix b/modules/hardware-generic.nix index f7500c2e..97acb9ad 100644 --- a/modules/hardware-generic.nix +++ b/modules/hardware-generic.nix @@ -15,6 +15,6 @@ in }; config = { - mobile.system.platform = lib.mkIf cfg.generic-x86_64.enable "x86_64-linux"; + mobile.system.system = lib.mkIf cfg.generic-x86_64.enable "x86_64-linux"; }; } diff --git a/modules/hardware-qualcomm.nix b/modules/hardware-qualcomm.nix index 3155d11c..ffa255e0 100644 --- a/modules/hardware-qualcomm.nix +++ b/modules/hardware-qualcomm.nix @@ -27,19 +27,19 @@ in config = mkMerge [ { mobile = mkIf cfg.qualcomm-msm8939.enable { - system.platform = "aarch64-linux"; + system.system = "aarch64-linux"; quirks.qualcomm.msm-fb-handle.enable = true; }; } { mobile = mkIf cfg.qualcomm-msm8953.enable { - system.platform = "aarch64-linux"; + system.system = "aarch64-linux"; quirks.qualcomm.msm-fb-handle.enable = true; }; } { mobile = mkIf cfg.qualcomm-apq8064-1aa.enable { - system.platform = "armv7a-linux"; + system.system = "armv7l-linux"; quirks.qualcomm.msm-fb-refresher.enable = true; }; } diff --git a/modules/hardware-rockchip.nix b/modules/hardware-rockchip.nix index 425c788a..c4f34a41 100644 --- a/modules/hardware-rockchip.nix +++ b/modules/hardware-rockchip.nix @@ -17,7 +17,7 @@ in config = mkMerge [ { mobile = mkIf cfg.rockchip-op1.enable { - system.platform = "aarch64-linux"; + system.system = "aarch64-linux"; }; } ]; diff --git a/modules/system-target.nix b/modules/system-target.nix index 6b04d1d5..53497f44 100644 --- a/modules/system-target.nix +++ b/modules/system-target.nix @@ -1,24 +1,35 @@ { config, lib, pkgs, ... }: -# FIXME : current implementation only works for native x86_64 built hosts. - with lib; let cfg = config.mobile.system; - target_types = { - aarch64-linux = lib.systems.examples.aarch64-multiplatform; - armv7a-linux = lib.systems.examples.armv7l-hf-multiplatform; - x86_64-linux = { config = "x86_64-unknown-linux-gnu"; }; + # Mapping from system types to config types + # A simplified view of + config_types = { + aarch64-linux = "aarch64-unknown-linux-gnu"; + armv7l-linux = "armv7l-unknown-linux-gnueabihf"; + x86_64-linux = "x86_64-unknown-linux-gnu"; }; - # Hmmm, this doesn't feel right, but it does work. - host_platform = (import {}).buildPackages.hostPlatform; + # Derived from config_types + target_types = lib.attrNames config_types; + + # Builds the expected "platform" set for cross-compilation from the given + # system name. + selectPlatform = system: { + inherit system; + platform = lib.systems.platforms.selectBySystem system; + config = config_types.${system}; + }; + + # The platform selected by the configuration + selectedPlatform = selectPlatform cfg.system; in { options.mobile = { - system.platform = mkOption { - type = types.enum (lib.attrNames target_types); + system.system = mkOption { + type = types.enum target_types; description = '' Defines the kind of target architecture system the device is. @@ -30,14 +41,25 @@ in config = { assertions = [ { - assertion = pkgs.targetPlatform.system == cfg.platform; - message = "pkgs.targetPlatform.system expected to be `${cfg.platform}`, is `${pkgs.targetPlatform.system}`"; + assertion = pkgs.targetPlatform.system == cfg.system; + message = "pkgs.targetPlatform.system expected to be `${cfg.system}`, is `${pkgs.targetPlatform.system}`"; } ]; nixpkgs.crossSystem = lib.mkIf - ( target_types.${cfg.platform}.config != host_platform.config ) - (target_types.${cfg.platform} // { system = cfg.platform; }) # FIXME : WHY? I didn't need to add system before :/ + ( + let + result = selectedPlatform.system != builtins.currentSystem; + in + builtins.trace + "Building with crossSystem?: ${selectedPlatform.system} != ${builtins.currentSystem} → ${if result then "true" else "false"}" + result + ) + ( + builtins.trace + " crossSystem: config: ${selectedPlatform.config}" + selectedPlatform + ) ; }; }