nixos-config/modules/devices.nix

53 lines
1.5 KiB
Nix
Raw Normal View History

2020-02-17 17:00:59 +04:00
{ pkgs, lib, config, ... }:
with lib;
with types; {
options = {
2021-01-21 22:13:53 +04:00
device = mkOption { type = str; };
deviceSpecific = {
isLaptop = mkOption {
type = bool;
default =
!isNull (builtins.match ".*Laptop" config.networking.hostName);
2020-02-17 17:00:59 +04:00
};
2023-02-22 00:34:25 +04:00
isPhone = mkOption {
type = bool;
default = !isNull (builtins.match ".*Phone" config.networking.hostName);
};
2021-01-21 22:13:53 +04:00
devInfo = {
2020-11-09 23:43:06 +04:00
cpu = {
2021-01-21 22:13:53 +04:00
arch = mkOption { type = enum [ "x86_64" "aarch64" ]; };
vendor = mkOption { type = enum [ "amd" "intel" "broadcom" ]; };
clock = mkOption { type = int; };
cores = mkOption { type = int; };
2020-11-09 23:43:06 +04:00
};
drive = {
2021-01-21 22:13:53 +04:00
type = mkOption { type = enum [ "hdd" "ssd" ]; };
speed = mkOption { type = int; };
size = mkOption { type = int; };
2020-11-09 23:43:06 +04:00
};
2021-01-21 22:13:53 +04:00
ram = mkOption { type = int; };
2021-01-22 21:44:23 +04:00
legacy = mkOption { type = bool; default = false; };
2021-01-21 22:13:53 +04:00
bigScreen = mkOption {
type = bool;
default = true;
2020-02-17 17:00:59 +04:00
};
};
2021-01-21 22:13:53 +04:00
# Whether machine is powerful enough for heavy stuff
goodMachine = with config.deviceSpecific;
mkOption {
type = bool;
default = devInfo.cpu.clock * devInfo.cpu.cores >= 4000
&& devInfo.drive.size >= 100 && devInfo.ram >= 8;
};
isHost = mkOption {
type = bool;
2021-02-01 20:54:45 +04:00
default = false;
2021-01-21 22:13:53 +04:00
};
bigScreen = mkOption {
type = bool;
default = config.deviceSpecific.devInfo ? bigScreen;
};
2020-02-17 17:00:59 +04:00
};
};
}