add (device options): add zram and laptop config options
This commit is contained in:
parent
83c8ef2a42
commit
cb33cd4006
4 changed files with 146 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ deviceName:
|
||||||
let
|
let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
|
|
||||||
|
CustomOptions = ../options;
|
||||||
customFunctions = import ./utils.nix { inherit lib; };
|
customFunctions = import ./utils.nix { inherit lib; };
|
||||||
|
|
||||||
baseOverlays =
|
baseOverlays =
|
||||||
|
|
@ -56,6 +57,7 @@ lib.nixosSystem {
|
||||||
specialArgs = additionalArgs;
|
specialArgs = additionalArgs;
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
|
CustomOptions
|
||||||
DeviceConfig
|
DeviceConfig
|
||||||
HostConfig
|
HostConfig
|
||||||
|
|
||||||
|
|
|
||||||
7
options/default.nix
Normal file
7
options/default.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{ customFunctions, ... }:
|
||||||
|
{
|
||||||
|
imports = customFunctions.scan {
|
||||||
|
path = ./.;
|
||||||
|
exclude = [ ./default.nix ];
|
||||||
|
};
|
||||||
|
}
|
||||||
115
options/device/desktop.nix
Normal file
115
options/device/desktop.nix
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
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 = true;
|
||||||
|
description = "Battery configuration for the laptop.";
|
||||||
|
};
|
||||||
|
|
||||||
|
bluetooth.enable = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Bluetooth configuration for the laptop.";
|
||||||
|
};
|
||||||
|
|
||||||
|
cpu.type = lib.mkOption {
|
||||||
|
type = lib.enum [
|
||||||
|
"intel"
|
||||||
|
"amd"
|
||||||
|
];
|
||||||
|
default = "intel";
|
||||||
|
description = "Laptop CPU type.";
|
||||||
|
};
|
||||||
|
|
||||||
|
sound.enable = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
imports = lib.optional (
|
||||||
|
cfg.cpu.type == "intel"
|
||||||
|
) inputs.nixos-hardware.nixosModules.common-cpu-intel;
|
||||||
|
services.thermald =
|
||||||
|
lib.mkIf cfg.cpu.type == "intel" {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.thermald;
|
||||||
|
};
|
||||||
|
hardware.graphics =
|
||||||
|
lib.mkIf cfg.cpu.type == "intel" {
|
||||||
|
enable = true;
|
||||||
|
enable32Bit = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
security.rtkit.enable = lib.mkIf cfg.sound.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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
22
options/device/zram.nix
Normal file
22
options/device/zram.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{ lib, config, ... }:
|
||||||
|
let
|
||||||
|
cfg = device.zram;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
device.zram = {
|
||||||
|
enable = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Zram settings for the device.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
zramSwap = {
|
||||||
|
enable = true;
|
||||||
|
memoryPercent = 100;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in a new issue