1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 19:23:01 +03:00
mobile-nixos/modules/system-target.nix

41 lines
1.1 KiB
Nix
Raw Normal View History

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;
x86_64-linux = { config = "x86_64-unknown-linux-gnu"; };
2018-06-27 04:52:09 +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
}
];
nixpkgs.crossSystem = lib.mkIf ( target_types.${cfg.platform}.config != host_platform.config ) target_types.${cfg.platform};
2018-06-27 04:52:09 +03:00
};
}