1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 11:03:37 +03:00
mobile-nixos/modules/system-types.nix

48 lines
1.2 KiB
Nix
Raw Normal View History

{ 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);
system_type = config.mobile.system.type;
known_system_types = config.mobile.system.types;
in
{
2019-09-22 00:30:12 +03:00
imports = [
../systems/rootfs.nix
2019-09-22 05:41:33 +03:00
./system-types/kernel-initrd.nix
2019-09-22 00:30:12 +03:00
];
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}";
}
];
};
}