nixos-config/modules/devices.nix

79 lines
1.8 KiB
Nix
Raw Normal View History

2019-08-27 23:41:02 +04:00
{ pkgs, lib, config, ... }:
with lib;
with types; {
options = {
2020-08-05 04:52:30 +04:00
device = mkOption { type = strMatching "[A-z|0-9]*-(Laptop|Workstation|VM)"; };
2019-08-27 23:41:02 +04:00
devices = mkOption { type = attrs; };
deviceSpecific = mkOption { type = attrs; };
};
config = {
deviceSpecific = let
device = config.device;
devInfo = config.devices.${config.device};
in rec {
isLaptop = (!isNull (builtins.match ".*Laptop" device));
2019-09-14 22:12:56 +04:00
isVM = (!isNull (builtins.match ".*VM" device));
2020-02-05 04:30:49 +04:00
isHost = (device == "AMD-Workstation");
2019-08-27 23:41:02 +04:00
isShared = devInfo.isShared;
2020-08-05 04:52:30 +04:00
isSSD = devInfo.drive.type == "ssd";
smallScreen = (device == "Dell-Laptop");
2019-08-27 23:41:02 +04:00
cpu = devInfo.cpu.vendor;
2019-09-14 22:12:56 +04:00
video = devInfo.video;
2020-09-26 03:33:55 +04:00
ram = devInfo.ram;
2020-03-22 01:07:54 +04:00
enableVirtualisation = devInfo.enableVirtualisation;
2020-08-29 17:47:21 +04:00
isGaming = devInfo.gaming;
2019-08-27 23:41:02 +04:00
};
devices = {
AMD-Workstation = {
cpu = {
vendor = "amd";
2020-08-05 04:52:30 +04:00
clock = 3700;
threads = 12;
2019-08-27 23:41:02 +04:00
};
drive = {
type = "ssd";
size = 250;
};
2019-09-14 22:12:56 +04:00
video = "amd";
2019-08-27 23:41:02 +04:00
ram = 16;
isShared = false;
2020-03-22 01:07:54 +04:00
enableVirtualisation = true;
2020-08-29 17:47:21 +04:00
gaming = true;
2019-08-27 23:41:02 +04:00
};
2019-09-13 14:20:04 +04:00
Dell-Laptop = {
cpu = {
vendor = "intel";
clock = 1600;
2020-08-05 04:52:30 +04:00
threads = 8;
2019-09-13 14:20:04 +04:00
};
drive = {
type = "ssd";
size = 250;
};
2019-09-14 22:12:56 +04:00
video = "intel";
2020-08-05 04:52:30 +04:00
ram = 16;
2020-02-07 03:07:12 +04:00
isShared = false;
2020-04-26 14:48:24 +04:00
enableVirtualisation = false;
2020-08-29 17:47:21 +04:00
gaming = true;
2019-09-13 14:20:04 +04:00
};
2019-08-27 23:41:02 +04:00
NixOS-VM = {
cpu = {
vendor = "amd";
2020-08-05 04:52:30 +04:00
clock = 3700;
threads = 4;
2019-08-27 23:41:02 +04:00
};
drive = {
type = "ssd";
2020-08-05 04:52:30 +04:00
size = 20;
2019-08-27 23:41:02 +04:00
};
2019-09-14 22:12:56 +04:00
video = "virtualbox";
2019-08-27 23:41:02 +04:00
ram = 4;
isShared = false;
2020-03-22 01:07:54 +04:00
enableVirtualisation = false;
2020-08-29 17:47:21 +04:00
gaming = false;
2019-08-27 23:41:02 +04:00
};
};
};
}