Add laptop module

This commit is contained in:
Yorick Barbanneau 2023-12-26 00:57:35 +01:00
parent 2888303bb0
commit 559a477e05
5 changed files with 49 additions and 13 deletions

View file

@ -20,9 +20,7 @@ in rec {
hostname = "morty";
username = "ephase";
hostConfig = {
gaming = true;
desktop = true;
laptop = true;
};
};
modules = [
@ -37,9 +35,7 @@ in rec {
hostname = "mrmeeseeks";
username = "ephase";
hostConfig = {
gaming = true;
desktop = true;
laptop = false;
};
};
modules = [
@ -54,9 +50,7 @@ in rec {
hostname = "luci";
username = "ephase";
hostConfig = {
gaming = false;
desktop = true;
laptop = true;
};
};
modules = [

View file

@ -1,3 +1,4 @@
{ ... }: {
config.modules.gaming.steam.enable = true;
config.modules.hardware.laptop.enable = true;
}

View file

@ -2,5 +2,6 @@ _:
{
imports = [
./gaming/steam
./hardware/laptop
];
}

View file

@ -0,0 +1,47 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.hardware.laptop;
in
{
options.modules.hardware.laptop = {
enable = mkEnableOption "Install Laptop utils";
governor_battery = mkOption {
type = types.str;
default = "powersave";
};
turbo_battery = mkOption {
type = types.enum ["always" "never" "auto"];
default = "never";
};
governor_ac = mkOption {
type = types.str;
default = "schedutil";
};
turbo_ac = mkOption {
type = types.enum ["always" "never" "auto"];
default = "never";
};
};
config = mkIf cfg.enable {
# Wifi is installed on laptops
networking.wireless.iwd.enable = true;
# And cpufreq
services.auto-cpufreq = {
enable = true;
settings = {
battery = {
governor = cfg.governor_battery;
turbo = cfg.turbo_battery;
};
charger = {
governor = cfg.governor_ac;
turbo = cfg.turbo_ac;
};
};
};
};
}

View file

@ -22,13 +22,6 @@
./includes/desktop/xdg-portal.nix
]
else []
) ++ (
if hostConfig.laptop then
[
./includes/hardware/iwd.nix
./includes/hardware/cpufreq.nix
]
else []
);