clear (refactor options): refactor options

This commit is contained in:
Kirill Samoylenkov 2025-10-01 20:20:47 +05:00
parent 00ea2b0c36
commit bfce36ce73
22 changed files with 340 additions and 463 deletions

View file

@ -5,57 +5,36 @@
...
}:
let
inherit (lib) mkOption mkEnableOption mkIf;
inherit (lib.types) enum;
cfg = config.device.laptop;
in
{
options = {
device.laptop = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Settings for the laptop.";
};
options.device.laptop = {
enable = mkEnableOption "Settings for the laptop.";
battery.enable = mkEnableOption "Battery configuration for the laptop.";
bluetooth.enable = mkEnableOption "Bluetooth configuration for the laptop.";
sound.enable = mkEnableOption "Sound configuration for the laptop.";
battery.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Battery configuration for the laptop.";
};
cpu = {
# FIXME: Additional imports for devices config:
# inputs.nixos-hardware.nixosModules.common-cpu-intel
enable = mkEnableOption "CPU configuration for the laptop.";
bluetooth.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Bluetooth configuration for the laptop.";
};
cpu = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "CPU configuration for the laptop.";
};
type = lib.mkOption {
type = lib.types.enum [
"intel"
"amd"
];
default = "intel";
description = "Laptop CPU type.";
};
# FIXME: Additional imports for devices config:
# inputs.nixos-hardware.nixosModules.common-cpu-intel
};
sound.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Sound configuration for the laptop.";
platform = mkOption {
type = enum [
"intel"
"amd"
];
default = "intel";
description = "Laptop CPU type.";
};
};
};
config = lib.mkIf cfg.enable {
services.tlp = lib.mkIf cfg.battery.enable {
config = mkIf cfg.enable {
services.tlp = mkIf cfg.battery.enable {
enable = true;
settings = {
PLATFORM_PROFILE_ON_AC = "performance";
@ -78,7 +57,7 @@ in
};
};
hardware.bluetooth = lib.mkIf cfg.bluetooth.enable {
hardware.bluetooth = mkIf cfg.bluetooth.enable {
enable = true;
powerOnBoot = false;
settings = {
@ -88,26 +67,26 @@ in
};
};
};
services.blueman = lib.mkIf cfg.bluetooth.enable {
services.blueman = mkIf cfg.bluetooth.enable {
enable = true;
};
services.thermald = lib.mkIf (cfg.cpu.enable && cfg.cpu.type == "intel") {
services.thermald = mkIf (cfg.cpu.enable && cfg.cpu.platform == "intel") {
enable = true;
package = pkgs.thermald;
};
hardware.graphics = lib.mkIf (cfg.cpu.enable && cfg.cpu.type == "intel") {
hardware.graphics = mkIf (cfg.cpu.enable && cfg.cpu.platform == "intel") {
enable = true;
enable32Bit = true;
};
security.rtkit = lib.mkIf cfg.sound.enable {
security.rtkit = mkIf cfg.sound.enable {
enable = true;
};
services.pulseaudio = lib.mkIf cfg.sound.enable {
services.pulseaudio = mkIf cfg.sound.enable {
enable = false;
};
services.pipewire = lib.mkIf cfg.sound.enable {
services.pipewire = mkIf cfg.sound.enable {
enable = true;
pulse.enable = true;
wireplumber.enable = true;