120 lines
2.8 KiB
Nix
120 lines
2.8 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.device.laptop;
|
|
in
|
|
{
|
|
options = {
|
|
device.laptop = {
|
|
enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Settings for the laptop.";
|
|
};
|
|
|
|
battery.enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Battery 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.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
services.tlp = lib.mkIf cfg.battery.enable {
|
|
enable = true;
|
|
settings = {
|
|
PLATFORM_PROFILE_ON_AC = "performance";
|
|
PLATFORM_PROFILE_ON_BAT = "balanced";
|
|
|
|
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
|
|
CPU_ENERGY_PERF_POLICY_ON_BAT = "balanced";
|
|
|
|
CPU_BOOST_ON_AC = 1;
|
|
CPU_BOOST_ON_BAT = 0;
|
|
|
|
CPU_MIN_PERF_ON_AC = 0;
|
|
CPU_MAX_PERF_ON_AC = 100;
|
|
|
|
CPU_MIN_PERF_ON_BAT = 0;
|
|
CPU_MAX_PERF_ON_BAT = 40;
|
|
|
|
START_CHARGE_THRESH_BAT0 = 0;
|
|
STOP_CHARGE_THRESH_BAT0 = 1;
|
|
};
|
|
};
|
|
|
|
hardware.bluetooth = lib.mkIf cfg.bluetooth.enable {
|
|
enable = true;
|
|
powerOnBoot = false;
|
|
settings = {
|
|
General = {
|
|
Enable = "Source,Sink,Media,Socket";
|
|
Experimental = true;
|
|
};
|
|
};
|
|
};
|
|
services.blueman = lib.mkIf cfg.bluetooth.enable {
|
|
enable = true;
|
|
};
|
|
|
|
services.thermald = lib.mkIf (cfg.cpu.enable && cfg.cpu.type == "intel") {
|
|
enable = true;
|
|
package = pkgs.thermald;
|
|
};
|
|
hardware.graphics = lib.mkIf (cfg.cpu.enable && cfg.cpu.type == "intel") {
|
|
enable = true;
|
|
enable32Bit = true;
|
|
};
|
|
|
|
security.rtkit = lib.mkIf cfg.sound.enable {
|
|
enable = true;
|
|
};
|
|
services.pulseaudio = lib.mkIf cfg.sound.enable {
|
|
enable = false;
|
|
};
|
|
services.pipewire = lib.mkIf cfg.sound.enable {
|
|
enable = true;
|
|
pulse.enable = true;
|
|
wireplumber.enable = true;
|
|
alsa = {
|
|
enable = true;
|
|
support32Bit = true;
|
|
};
|
|
};
|
|
};
|
|
}
|