mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-28 10:26:55 +03:00
system-target: reviews implementation
Since the initial implementation I learned enough to know where it was slighly wrong. I think this fixes most of the slight wrongness.
This commit is contained in:
parent
3c1408c82d
commit
c1acf97334
@ -13,7 +13,7 @@
|
|||||||
# This is because motorola ships an armv7l userspace from stock ROM.
|
# This is because motorola ships an armv7l userspace from stock ROM.
|
||||||
#
|
#
|
||||||
# in local.nix:
|
# in local.nix:
|
||||||
# mobile.system.platform = lib.mkForce "armv7a-linux";
|
# mobile.system.system = lib.mkForce "armv7l-linux";
|
||||||
#
|
#
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -15,6 +15,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
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";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -27,19 +27,19 @@ in
|
|||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
{
|
{
|
||||||
mobile = mkIf cfg.qualcomm-msm8939.enable {
|
mobile = mkIf cfg.qualcomm-msm8939.enable {
|
||||||
system.platform = "aarch64-linux";
|
system.system = "aarch64-linux";
|
||||||
quirks.qualcomm.msm-fb-handle.enable = true;
|
quirks.qualcomm.msm-fb-handle.enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mobile = mkIf cfg.qualcomm-msm8953.enable {
|
mobile = mkIf cfg.qualcomm-msm8953.enable {
|
||||||
system.platform = "aarch64-linux";
|
system.system = "aarch64-linux";
|
||||||
quirks.qualcomm.msm-fb-handle.enable = true;
|
quirks.qualcomm.msm-fb-handle.enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
mobile = mkIf cfg.qualcomm-apq8064-1aa.enable {
|
mobile = mkIf cfg.qualcomm-apq8064-1aa.enable {
|
||||||
system.platform = "armv7a-linux";
|
system.system = "armv7l-linux";
|
||||||
quirks.qualcomm.msm-fb-refresher.enable = true;
|
quirks.qualcomm.msm-fb-refresher.enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ in
|
|||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
{
|
{
|
||||||
mobile = mkIf cfg.rockchip-op1.enable {
|
mobile = mkIf cfg.rockchip-op1.enable {
|
||||||
system.platform = "aarch64-linux";
|
system.system = "aarch64-linux";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -1,24 +1,35 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
# FIXME : current implementation only works for native x86_64 built hosts.
|
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.mobile.system;
|
cfg = config.mobile.system;
|
||||||
|
|
||||||
target_types = {
|
# Mapping from system types to config types
|
||||||
aarch64-linux = lib.systems.examples.aarch64-multiplatform;
|
# A simplified view of <nixpkgs/lib/systems/examples.nix>
|
||||||
armv7a-linux = lib.systems.examples.armv7l-hf-multiplatform;
|
config_types = {
|
||||||
x86_64-linux = { config = "x86_64-unknown-linux-gnu"; };
|
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.
|
# Derived from config_types
|
||||||
host_platform = (import <nixpkgs> {}).buildPackages.hostPlatform;
|
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
|
in
|
||||||
{
|
{
|
||||||
options.mobile = {
|
options.mobile = {
|
||||||
system.platform = mkOption {
|
system.system = mkOption {
|
||||||
type = types.enum (lib.attrNames target_types);
|
type = types.enum target_types;
|
||||||
description = ''
|
description = ''
|
||||||
Defines the kind of target architecture system the device is.
|
Defines the kind of target architecture system the device is.
|
||||||
|
|
||||||
@ -30,14 +41,25 @@ in
|
|||||||
config = {
|
config = {
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = pkgs.targetPlatform.system == cfg.platform;
|
assertion = pkgs.targetPlatform.system == cfg.system;
|
||||||
message = "pkgs.targetPlatform.system expected to be `${cfg.platform}`, is `${pkgs.targetPlatform.system}`";
|
message = "pkgs.targetPlatform.system expected to be `${cfg.system}`, is `${pkgs.targetPlatform.system}`";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
nixpkgs.crossSystem = lib.mkIf
|
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
|
||||||
|
)
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user