mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-17 21:11:34 +03:00
692544a5ef
Closes #252. This uses the `lib.systems.elaborate` function which builds the complete attrset as preferred by Nixpkgs by using `lib.systems.elaborate`, rather than building a partial equivalent. @noneucat originally implemented it the simplest way possible, re-using parts of the now unneeded custom functions. We can, instead, simply pass a system name to `elaborate`, which ends up doing the right thing. Co-authored-by: Andy Chun <andy@lolc.at> Co-authored-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
53 lines
1.3 KiB
Nix
53 lines
1.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
let
|
|
cfg = config.mobile.system;
|
|
inherit (config.nixpkgs) localSystem;
|
|
|
|
# The platform selected by the configuration
|
|
selectedPlatform = lib.systems.elaborate cfg.system;
|
|
in
|
|
{
|
|
options.mobile = {
|
|
system.system = mkOption {
|
|
# Known supported target types for Mobile NixOS
|
|
type = types.enum [
|
|
"aarch64-linux"
|
|
"armv7l-linux"
|
|
"x86_64-linux"
|
|
];
|
|
description = ''
|
|
Defines the kind of target architecture system the device is.
|
|
|
|
This will automagically setup cross-compilation where possible.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = {
|
|
assertions = [
|
|
{
|
|
assertion = pkgs.targetPlatform.system == cfg.system;
|
|
message = "pkgs.targetPlatform.system expected to be `${cfg.system}`, is `${pkgs.targetPlatform.system}`";
|
|
}
|
|
];
|
|
|
|
nixpkgs.crossSystem = lib.mkIf
|
|
(
|
|
let
|
|
result = selectedPlatform.system != localSystem.system;
|
|
in
|
|
builtins.trace
|
|
"Building with crossSystem?: ${selectedPlatform.system} != ${localSystem.system} → ${if result then "we are" else "we're not"}."
|
|
result
|
|
)
|
|
(
|
|
builtins.trace
|
|
" crossSystem: config: ${selectedPlatform.config}"
|
|
selectedPlatform
|
|
)
|
|
;
|
|
};
|
|
}
|