1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-17 21:11:34 +03:00
mobile-nixos/modules/system-target.nix

53 lines
1.3 KiB
Nix
Raw Normal View History

2018-06-27 04:52:09 +03:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.mobile.system;
inherit (config.nixpkgs) localSystem;
2018-06-27 04:52:09 +03:00
# The platform selected by the configuration
selectedPlatform = lib.systems.elaborate cfg.system;
2018-06-27 04:52:09 +03:00
in
{
options.mobile = {
system.system = mkOption {
# Known supported target types for Mobile NixOS
type = types.enum [
"aarch64-linux"
"armv7l-linux"
"x86_64-linux"
];
2018-06-27 04:52:09 +03:00
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}`";
2018-06-27 04:52:09 +03:00
}
];
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
)
;
2018-06-27 04:52:09 +03:00
};
}