1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 02:43:24 +03:00
mobile-nixos/modules/system-types.nix
Samuel Dionne-Riel dcbda16fc5 system-types: Rename kernel-initrd -> qemu-startscript
In addition, put the implementation of the build side-by-side with the
system type definition. It made no sense to keep those where they were,
as it was baggage from the earlier implementation of the project.
2020-05-15 16:10:43 -04:00

50 lines
1.2 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
failed = map (x: x.message) (filter (x: !x.assertion) config.assertions);
system_type = config.mobile.system.type;
known_system_types = config.mobile.system.types ++ [ "none" ];
in
{
imports = [
./system-types/depthcharge
./system-types/qemu-startscript
./system-types/android
./system-types/u-boot
];
options.mobile = {
system.types = mkOption {
type = types.listOf types.str;
internal = true;
description = ''
Registry of system types.
'';
};
system.type = mkOption {
type = types.enum known_system_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 known_system_types.
{
assertion = lib.lists.any (x: x == system_type) known_system_types;
message = "Cannot build unexpected system type: ${system_type}.\n Known types: ${lib.concatStringsSep ", " known_system_types}";
}
];
};
}