nixos-config/modules/devices.nix

158 lines
4.1 KiB
Nix
Raw Normal View History

2024-02-08 23:21:10 +03:00
{ lib, config, ... }:
2019-08-27 23:41:02 +04:00
with lib;
with types; {
options = {
2021-02-07 02:38:11 +03:00
device = mkOption { type = str; };
deviceSpecific = {
devInfo = {
2019-08-27 23:41:02 +04:00
cpu = {
2021-02-07 02:38:11 +03:00
arch = mkOption { type = enum [ "x86_64" "aarch64" ]; };
vendor = mkOption { type = enum [ "amd" "intel" "broadcom" ]; };
clock = mkOption { type = int; };
cores = mkOption { type = int; };
2019-08-27 23:41:02 +04:00
};
drive = {
2021-02-07 02:38:11 +03:00
type = mkOption { type = enum [ "hdd" "ssd" ]; };
speed = mkOption { type = int; };
size = mkOption { type = int; };
2019-08-27 23:41:02 +04:00
};
2021-02-07 02:38:11 +03:00
gpu = {
2021-09-15 18:37:57 +03:00
vendor = mkOption { type = enum [ "amd" "nvidia" "intel" "vm" "other" ]; };
2019-09-13 14:20:04 +04:00
};
2022-10-08 04:32:18 +03:00
fileSystem = mkOption { type = enum [ "btrfs" "zfs" "other" ]; default = "other"; };
2021-02-07 02:38:11 +03:00
ram = mkOption { type = int; };
legacy = mkOption { type = bool; default = false; };
bigScreen = mkOption {
type = bool;
default = true;
2019-09-13 14:20:04 +04:00
};
};
2021-02-07 02:38:11 +03:00
isLaptop = mkOption {
type = bool;
default =
2023-01-26 02:12:00 +03:00
(builtins.match ".*Laptop" config.networking.hostName) != null;
2021-02-07 02:38:11 +03:00
};
isVM = mkOption {
type = bool;
default =
2023-01-26 02:12:00 +03:00
(builtins.match ".*VM" config.networking.hostName) != null;
2021-10-24 23:12:25 +03:00
};
2021-10-25 23:13:24 +03:00
isServer = mkOption {
2021-10-24 23:12:25 +03:00
type = bool;
default =
2023-01-26 02:12:00 +03:00
(builtins.match ".*(Cloud|Server)" config.networking.hostName) != null;
2022-02-11 14:07:03 +03:00
};
isContainer = mkOption {
type = bool;
default =
2023-01-26 02:12:00 +03:00
(builtins.match ".*(CT|Container)" config.networking.hostName) != null;
2021-02-07 02:38:11 +03:00
};
2021-06-16 05:30:04 +03:00
isISO = mkOption {
type = bool;
default =
2023-01-26 02:12:00 +03:00
(builtins.match ".*ISO" config.networking.hostName) != null;
2021-06-16 05:30:04 +03:00
};
2021-09-15 18:37:57 +03:00
isDesktop = mkOption {
type = bool;
default = with config.deviceSpecific; (!isLaptop && !isVM && !isISO);
};
2021-02-07 02:38:11 +03:00
isHost = mkOption {
type = bool;
default = false;
};
isShared = mkOption {
type = bool;
default = false;
};
isGaming = mkOption {
type = bool;
default = false;
};
enableVirtualisation = mkOption {
type = bool;
default = config.deviceSpecific.isHost;
};
isSSD = mkOption {
type = bool;
default = config.deviceSpecific.devInfo.drive.type == "ssd";
2019-08-27 23:41:02 +04:00
};
2023-01-26 00:15:51 +03:00
vpn = {
mullvad.enable = mkOption {
2021-06-16 23:42:44 +03:00
type = bool;
default = false;
};
2023-04-15 03:18:30 +03:00
ivpn.enable = mkOption {
type = bool;
default = false;
};
2023-01-26 00:15:51 +03:00
tailscale.enable = mkOption {
2021-06-16 23:42:44 +03:00
type = bool;
2023-01-26 00:15:51 +03:00
default = false;
2021-06-16 23:42:44 +03:00
};
sing-box.enable = mkOption {
type = bool;
default = false;
};
sing-box.config = mkOption {
type = str;
default = "";
};
2023-07-05 20:42:56 +03:00
wireguard = {
enable = mkOption {
type = bool;
default = false;
};
autostart = mkOption {
type = bool;
default = false;
};
port = mkOption {
type = int;
default = 51820;
};
endpoint = mkOption {
type = str;
default = "";
};
address = mkOption {
type = listOf str;
default = [];
};
allowedIPs = mkOption {
type = listOf str;
default = [];
};
dns = mkOption {
type = listOf str;
default = [];
};
gateway = {
ipv4 = mkOption {
type = nullOr str;
default = null;
};
ipv6 = mkOption {
type = nullOr str;
default = null;
};
};
keys = {
public = mkOption {
type = nullOr str;
default = null;
};
presharedFile = mkOption {
type = nullOr path;
default = null;
};
privateFile = mkOption {
type = nullOr path;
default = null;
};
};
};
2021-06-16 23:42:44 +03:00
};
2019-08-27 23:41:02 +04:00
};
};
}