refactor(systemModules): remove device module for new host module

This commit is contained in:
ooks-io 2024-04-29 18:49:12 +12:00
parent 7a74befde3
commit 956ae9448e
16 changed files with 0 additions and 435 deletions

View file

@ -1,7 +0,0 @@
{
imports = [
./function
./type
./hardware
];
}

View file

@ -1,13 +0,0 @@
{ lib, ... }:
let
inherit (lib) types mkOption;
in
{
options.systemModules.device.function = mkOption {
type = with types; listOf (enum ["workstation" "media server" "gaming"]);
default = [];
description = "Primary function/s of the device";
};
}

View file

@ -1,43 +0,0 @@
{ lib, config, pkgs, ... }:
let
inherit (lib) mkMerge mkEnableOption mkIf versionAtLeast versionOlder;
hardware = config.systemModules.hardware.cpu;
cfg = hardware.amd;
kernelVersion = config.kernelPackages.kernel.version;
kernelVersionAtLeast = versionAtLeast kernelVersion;
kernelVersionOlder= versionOlder kernelVersion;
in
{
options.systemModules.hardware.cpu.amd = {
pstate.enable = mkEnableOption "Enable pstate amd module";
};
config = mkIf (builtins.elem hardware.type ["amd"]) {
environment.systemPackages = [pkgs.amdctl];
hardware.cpu.amd.updateMicrocode = true;
boot = mkMerge [
{
kernelModules = [
"amd-pstate"
"amd-kvm" # virtulization
"msr" # required for amdctl
];
}
(mkIf (cfg.pstate.enable && (kernelVersionAtLeast "5.27") && (kernelVersionOlder "6.1")) {
kernelParams = ["initcall_blacklist-acpi_cpufreq_init"];
kernelModules = ["amd-pstate"];
})
(mkIf (cfg.pstate.enable && (kernelVersionAtLeast "6.1") && (kernelVersionOlder "6.3")) {
kernelParams = ["amd_pstate=passive"];
})
(mkIf (cfg.pstate.enable && (kernelVersionAtLeast "6.3")) {
kernelParams = ["amd_pstate=active"];
})
];
};
}

View file

@ -1,18 +0,0 @@
{ lib, ... }:
let
inherit (lib) types mkOption;
in
{
imports = [
./amd
./intel
];
options.systemModules.hardware.cpu.type = mkOption {
type = with types; nullOr (enum ["intel" "amd"]);
default = null;
description = "Type of cpu system module to use";
};
}

View file

@ -1,20 +0,0 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf;
inherit (builtins) elem;
hardware = config.systemModules.hardware.cpu;
in
{
# TODO: put kvm/gvt behind virtualization module flag
config = mkIf (elem hardware.type ["intel"]) {
boot = {
kernelModules = ["kvm-intel"];
kernelParams = ["i915.fastboot=1" "enable_gvt=1"];
};
hardware.cpu.intel.updateMicrocode = true;
environment.systemPackages = [pkgs.intel-gpu-tools];
};
}

View file

@ -1,8 +0,0 @@
{
imports = [
./cpu
./gpu
./features
./ssd
];
}

View file

@ -1,13 +0,0 @@
{ lib, config, ... }:
let
features = config.systemModules.hardware.features;
inherit (lib) mkIf;
inherit (builtins) elem;
in
{
config = mkIf (elem "backlight" features) {
hardware.brillo.enable = true;
};
}

View file

@ -1,94 +0,0 @@
{ lib, config, pkgs, ... }:
let
features = config.systemModules.hardware.features;
cfg = config.systemModules.hardware.battery;
inherit (lib) mkIf mkDefault mkOption types;
inherit (builtins) elem;
MHz = x: x * 1000;
in
{
options.systemModules.hardware.battery = {
powersave = {
minFreq = mkOption {
type = types.int;
default = 800;
description = "Minimum frequency for powersave mode in MHz";
};
maxFreq = mkOption {
type = types.int;
default = 1100;
description = "Maximum frequency for powersave mode in MHz";
};
};
performance = {
minFreq = mkOption {
type = types.int;
default = 1500;
description = "Minimum frequency for performance mode in MHz";
};
maxFreq = mkOption {
type = types.int;
default = 2600;
description = "Maximum frequency for performance mode in MHz";
};
};
};
config = mkIf (elem "battery" features) {
boot = {
kernelModules = ["acpi_call"];
extraModulePackages = with config.boot.kernelPackages; [
acpi_call
cpupower
];
};
services = {
auto-cpufreq = {
enable = true;
settings = {
battery = {
governor = "powersave";
scaling_min_freq = mkDefault (MHz cfg.powersave.minFreq);
scaling_max_freq = mkDefault (MHz cfg.powersave.maxFreq);
turbo = "never";
};
charger = {
governor = "performance";
scaling_min_freq = mkDefault (MHz cfg.performance.minFreq);
scaling_max_freq = mkDefault (MHz cfg.performance.maxFreq);
turbo = "auto";
};
};
};
upower = {
enable = true;
percentageLow = 25;
percentageCritical = 5;
percentageAction = 3;
criticalPowerAction = "Hibernate";
};
undervolt = {
enable = true;
tempBat = 65;
};
thermald.enable = true;
power-profiles-daemon.enable = true;
logind = {
lidSwitch = "suspend";
};
};
environment.systemPackages = with pkgs; [
acpi
powertop
];
};
}

View file

@ -1,24 +0,0 @@
{ config, lib, pkgs, ... }:
let
features = config.systemModules.hardware.features;
inherit (lib) mkIf;
inherit (builtins) elem;
in
{
config = mkIf (elem "bluetooth" features) {
hardware.bluetooth = {
enable = true;
package = pkgs.bluez5-experimental;
};
environment.systemPackages = with pkgs; [
live-buds-cli
bluetuith
];
# https://github.com/NixOS/nixpkgs/issues/114222
systemd.user.services.telephony_client.enable = false;
};
}

View file

@ -1,19 +0,0 @@
{ lib, config, ... }:
let
inherit (lib) types mkOption;
in
{
imports = [
./bluetooth
./backlight
./battery
];
options.systemModules.hardware.features = mkOption {
type = with types; listOf (enum ["bluetooth" "backlight" "battery"]);
default = [];
description = "What extra hardware feature system modules to use";
};
}

View file

@ -1,29 +0,0 @@
{ config, lib, pkgs, ... }:
let
gpu = config.systemModules.hardware.gpu;
inherit (lib) mkIf mkDefault;
inherit (builtins) elem;
in
{
config = mkIf (elem gpu.type ["amd"]) {
hardware.opengl = {
extraPackages = with pkgs; [
vulkan-tools
vulkan-loader
vulkan-extension-layer
vulkan-validation-layers
# amdvlk
mesa
];
extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
};
boot = {
initrd.kernelModules = ["amdgpu"];
kernelModules = ["amdgpu"];
};
environment.systemPackages = [ pkgs.nvtopPackages.amd ];
services.xserver.videoDrivers = mkDefault ["modesetting" "amdgpu"];
};
}

View file

@ -1,19 +0,0 @@
{ lib, ... }:
let
inherit (lib) types mkOption;
in
{
imports = [
./amd
./intel
./nvidia
];
options.systemModules.hardware.gpu.type = mkOption {
type = with types; nullOr (enum ["intel" "amd" "nvidia"]);
default = null;
description = "Type of gpu system module to use";
};
}

View file

@ -1,37 +0,0 @@
{ config, lib, pkgs, ... }:
let
gpu = config.systemModules.hardware.gpu;
inherit (lib) mkIf;
inherit (builtins) elem;
# vaapiIntel = pkgs.vaapiIntel.override {enableHybridCodec = true;};
in
{
config = mkIf (elem gpu.type ["intel"]) {
services.xserver.videoDrivers = ["modesetting"];
hardware.opengl = {
extraPackages = with pkgs; [
vaapiIntel
vaapiVdpau
libvdpau-va-gl
intel-compute-runtime
intel-media-driver
];
extraPackages32 = with pkgs.pkgsi686Linux; [
vaapiIntel
vaapiVdpau
libvdpau-va-gl
intel-media-driver
];
};
boot.initrd.kernelModules = ["i915"];
environment.variables = mkIf config.hardware.opengl.enable {
VDPAU_DRIVER = "va_gl";
};
};
}

View file

@ -1,51 +0,0 @@
{ config, lib, pkgs, ... }:
let
gpu = config.systemModules.hardware.gpu;
inherit (lib) mkIf mkDefault;
inherit (builtins) elem;
production = config.boot.kernelPackages.nvidiaPackages.production;
# beta = config.boot.kernelPackages.nvidiaPackages.beta;
in
{
# TODO: make option to choose nvidia package
config = mkIf (elem gpu.type ["nvidia"]) {
hardware = {
nvidia = {
open = mkDefault true;
package = production;
forceFullCompositionPipeline = true;
nvidiaSettings = false;
nvidiaPersistenced = true;
modesetting.enable = true;
powerManagement = {
enable = mkDefault true;
finegrained = mkDefault false;
};
};
opengl = {
extraPackages = with pkgs; [ nvidia-vaapi-driver ];
extraPackages32 = with pkgs.pkgsi686Linux; [ nvidia-vaapi-driver ];
};
};
environment.systemPackages = with pkgs; [
libva
libva-utils
vulkan-loader
vulkan-validation-layers
vulkan-tools
vulkan-extension-layer
mesa
nvtopPackages.nvidia
];
environment.sessionVariables = {
LIBVA_DRIVER_NAME = "nvidia";
NVD_BACKEND = "direct";
};
};
}

View file

@ -1,26 +0,0 @@
{ lib, config, ... }:
let
cfg = config.systemModules.hardware.ssd;
inherit (lib) mkIf mkEnableOption;
in
{
options.systemModules.hardware.ssd = {
enable = mkEnableOption "Enable ssd module";
};
config = mkIf cfg.enable {
services.fstrim = {
enable = true;
};
# only run fstrim while connected on AC
systemd.services.fstrim = {
unitConfig.ConditionACPower = true;
serviceConfig = {
Nice = 19;
IOSchedulingClass = "idle";
};
};
};
}

View file

@ -1,14 +0,0 @@
{ lib, ... }:
let
inherit (lib) types mkOption;
in
{
options.systemModules.device.type = mkOption {
type = types.enum ["desktop" "server" "phone" "vm"];
default = "desktop";
description = "Define what type of device the host is";
};
}