feat: add hardware nixos module

This commit is contained in:
Dmitriy Kholkin 2025-06-07 17:33:23 +03:00
parent 821628a598
commit 250d76cf65
Signed by: AtaraxiaDev
GPG Key ID: FD266B810DF48DF2
3 changed files with 92 additions and 0 deletions

View File

@ -13,6 +13,8 @@ in
];
ataraxia.defaults.role = "desktop";
ataraxia.defaults.hardware.cpuVendor = "amd";
ataraxia.defaults.hardware.gpuVendor = "amd";
# Impermanence
ataraxia.filesystems.zfs.enable = true;
ataraxia.filesystems.zfs.eraseOnBoot.enable = true;

View File

@ -0,0 +1,88 @@
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.types) enum nullOr;
cfg = config.ataraxia.defaults.hardware;
in
{
options.ataraxia.defaults.hardware = {
enable = mkEnableOption "Default hardware settings";
graphics = mkEnableOption "Enable hardware.graphics module";
cpuVendor = mkOption {
default = null;
type = nullOr (enum [
"amd"
"intel"
]);
};
gpuVendor = mkOption {
default = null;
type = nullOr (enum [
"amd"
"intel"
"nvidia"
]);
};
};
config = mkIf cfg.enable (
lib.mkMerge [
{
hardware.cpu.${cfg.cpuVendor}.updateMicrocode = true;
hardware.enableRedistributableFirmware = true;
}
(lib.mkIf (cfg.graphics) {
boot.initrd.kernelModules =
if (cfg.gpuVendor == "amd") then
[
"amdgpu"
]
else if (cfg.gpuVendor == "intel") then
[
"i915"
]
else
[ ];
hardware.graphics = {
enable = true;
enable32Bit = true;
extraPackages =
if cfg.gpuVendor == "intel" then
[
pkgs.intel-media-driver
pkgs.intel-vaapi-driver
pkgs.libvdpau-va-gl
]
else
[ ];
};
hardware.amdgpu = lib.mkIf (cfg.gpuVendor == "amd") {
opencl.enable = false;
initrd.enable = config.boot.initrd.systemd.enable;
};
environment.sessionVariables =
if (cfg.gpuVendor == "intel") then
{
GST_VAAPI_ALL_DRIVERS = "1";
LIBVA_DRIVER_NAME = "iHD";
VDPAU_DRIVER = "va_gl";
}
else if (cfg.gpuVendor == "amd") then
{
AMD_VULKAN_ICD = "RADV";
}
else
{ };
})
]
);
}

View File

@ -33,6 +33,7 @@ in
config =
let
baseRole = {
ataraxia.defaults.hardware.enable = mkDefault true;
ataraxia.defaults.locale.enable = mkDefault true;
ataraxia.defaults.lix.enable = mkDefault true;
ataraxia.defaults.nix.enable = mkDefault true;
@ -65,6 +66,7 @@ in
time.timeZone = "Etc/UTC";
};
desktopRole = recursiveUpdate baseRole {
ataraxia.defaults.hardware.graphics = mkDefault true;
ataraxia.defaults.sound.enable = mkDefault true;
location = {