mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-11-28 12:56:54 +03:00
59 lines
1.8 KiB
Nix
59 lines
1.8 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
system_type = config.mobile.system.type;
|
|
device_config = config.mobile.device;
|
|
hardware_config = config.mobile.hardware;
|
|
stage-1 = config.mobile.boot.stage-1;
|
|
|
|
build_types = {
|
|
android-bootimg = pkgs.callPackage ../systems/bootimg.nix {
|
|
inherit device_config;
|
|
# XXX : this feels like a hack
|
|
initrd = pkgs.callPackage ../systems/initrd.nix { inherit device_config stage-1; };
|
|
};
|
|
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";
|
|
# Equivalent to:
|
|
# → nix-build nixos -I nixos-config=system-image.nix -A config.system.build.sdImage
|
|
path = ((import (pkgs.path + "/nixos")) { configuration = ../system-image.nix; }).config.system.build.sdImage;
|
|
}
|
|
];
|
|
};
|
|
in
|
|
{
|
|
options.mobile = {
|
|
system.type = mkOption {
|
|
type = types.enum (lib.attrNames build_types);
|
|
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.
|
|
{ assertion = build_types ? system_type; message = "cannot build unexpected system type: ${system_type}.";}
|
|
];
|
|
system = {
|
|
build = build_types."${system_type}";
|
|
};
|
|
};
|
|
}
|