2018-06-27 04:52:09 +03:00
|
|
|
{ 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;
|
2018-07-02 00:43:31 +03:00
|
|
|
armv7a-linux = lib.systems.examples.armv7l-hf-multiplatform;
|
2018-06-28 02:37:45 +03:00
|
|
|
x86_64-linux = { config = "x86_64-unknown-linux-gnu"; };
|
2018-06-27 04:52:09 +03:00
|
|
|
};
|
2018-06-28 02:37:45 +03:00
|
|
|
|
|
|
|
# Hmmm, this doesn't feel right, but it does work.
|
|
|
|
host_platform = (import <nixpkgs> {}).buildPackages.hostPlatform;
|
2018-06-27 04:52:09 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.mobile = {
|
|
|
|
system.platform = mkOption {
|
|
|
|
type = types.enum (lib.attrNames target_types);
|
|
|
|
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.platform;
|
2018-07-02 00:43:31 +03:00
|
|
|
message = "pkgs.targetPlatform.system expected to be `${cfg.platform}`, is `${pkgs.targetPlatform.system}`";
|
2018-06-27 04:52:09 +03:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2018-06-28 02:37:45 +03:00
|
|
|
nixpkgs.crossSystem = lib.mkIf ( target_types.${cfg.platform}.config != host_platform.config ) target_types.${cfg.platform};
|
2018-06-27 04:52:09 +03:00
|
|
|
};
|
|
|
|
}
|