2018-06-17 02:21:41 +03:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2018-06-27 04:54:41 +03:00
|
|
|
failed = map (x: x.message) (filter (x: !x.assertion) config.assertions);
|
|
|
|
|
2018-06-17 02:21:41 +03:00
|
|
|
system_type = config.mobile.system.type;
|
2018-06-17 03:43:19 +03:00
|
|
|
device_config = config.mobile.device;
|
2018-06-18 03:50:17 +03:00
|
|
|
hardware_config = config.mobile.hardware;
|
2018-06-17 03:43:19 +03:00
|
|
|
stage-1 = config.mobile.boot.stage-1;
|
2018-06-17 02:21:41 +03:00
|
|
|
|
|
|
|
build_types = {
|
2018-07-12 03:55:30 +03:00
|
|
|
android-device = pkgs.callPackage ../systems/android-device.nix {
|
|
|
|
inherit config;
|
|
|
|
};
|
2018-06-18 02:57:03 +03:00
|
|
|
android-bootimg = pkgs.callPackage ../systems/bootimg.nix {
|
2018-06-17 03:43:19 +03:00
|
|
|
inherit device_config;
|
|
|
|
# XXX : this feels like a hack
|
2018-06-18 02:57:03 +03:00
|
|
|
initrd = pkgs.callPackage ../systems/initrd.nix { inherit device_config stage-1; };
|
2018-06-17 03:43:19 +03:00
|
|
|
};
|
2019-09-22 00:30:45 +03:00
|
|
|
|
2019-09-10 21:49:50 +03:00
|
|
|
depthcharge = pkgs.callPackage ../systems/depthcharge {
|
|
|
|
inherit device_config;
|
|
|
|
initrd = pkgs.callPackage ../systems/initrd.nix { inherit device_config stage-1; };
|
2019-09-22 00:30:45 +03:00
|
|
|
system = config.system.build.rootfs;
|
2019-09-10 21:49:50 +03:00
|
|
|
};
|
2019-09-22 00:30:45 +03:00
|
|
|
|
2018-06-24 00:11:07 +03:00
|
|
|
kernel-initrd = pkgs.linkFarm "${device_config.name}-build" [
|
|
|
|
{
|
|
|
|
name = "kernel-initrd";
|
|
|
|
path = pkgs.callPackage ../systems/kernel-initrd.nix {
|
|
|
|
# FIXME this all feels a bit not enough generic.
|
|
|
|
inherit device_config hardware_config;
|
|
|
|
initrd = pkgs.callPackage ../systems/initrd.nix { inherit device_config stage-1; };
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "system";
|
2019-09-22 00:30:12 +03:00
|
|
|
path = config.system.build.rootfs;
|
2018-06-24 00:11:07 +03:00
|
|
|
}
|
|
|
|
];
|
2018-06-17 02:21:41 +03:00
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2019-09-22 00:30:12 +03:00
|
|
|
imports = [
|
|
|
|
../systems/rootfs.nix
|
|
|
|
# FIXME: factor out installation device profile.
|
|
|
|
<nixpkgs/nixos/modules/profiles/installation-device.nix>
|
|
|
|
];
|
|
|
|
|
2018-06-17 02:21:41 +03:00
|
|
|
options.mobile = {
|
|
|
|
system.type = mkOption {
|
2018-06-24 00:11:07 +03:00
|
|
|
type = types.enum (lib.attrNames build_types);
|
2018-06-17 02:21:41 +03:00
|
|
|
description = ''
|
|
|
|
Defines the kind of system the device is.
|
|
|
|
|
|
|
|
The different kind of system types will define the outputs
|
|
|
|
produced for the system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
assertions = [
|
|
|
|
# While the enum type is enough to implement value safety, this will help
|
|
|
|
# when implementing new platforms and not implementing them in build_types.
|
2018-06-27 05:07:14 +03:00
|
|
|
{ assertion = build_types ? ${system_type}; message = "Cannot build unexpected system type: ${system_type}.";}
|
2018-06-17 02:21:41 +03:00
|
|
|
];
|
|
|
|
system = {
|
2018-06-27 04:54:41 +03:00
|
|
|
build =
|
|
|
|
if failed == [] then
|
|
|
|
build_types."${system_type}"
|
|
|
|
else throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: " → ${x}") failed)}\n"
|
|
|
|
;
|
2018-06-17 02:21:41 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|