feat: add hardware nixos module
This commit is contained in:
parent
821628a598
commit
250d76cf65
@ -13,6 +13,8 @@ in
|
|||||||
];
|
];
|
||||||
|
|
||||||
ataraxia.defaults.role = "desktop";
|
ataraxia.defaults.role = "desktop";
|
||||||
|
ataraxia.defaults.hardware.cpuVendor = "amd";
|
||||||
|
ataraxia.defaults.hardware.gpuVendor = "amd";
|
||||||
# Impermanence
|
# Impermanence
|
||||||
ataraxia.filesystems.zfs.enable = true;
|
ataraxia.filesystems.zfs.enable = true;
|
||||||
ataraxia.filesystems.zfs.eraseOnBoot.enable = true;
|
ataraxia.filesystems.zfs.eraseOnBoot.enable = true;
|
||||||
|
88
modules/nixos/hardware/hardware.nix
Normal file
88
modules/nixos/hardware/hardware.nix
Normal 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
|
||||||
|
{ };
|
||||||
|
})
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
@ -33,6 +33,7 @@ in
|
|||||||
config =
|
config =
|
||||||
let
|
let
|
||||||
baseRole = {
|
baseRole = {
|
||||||
|
ataraxia.defaults.hardware.enable = mkDefault true;
|
||||||
ataraxia.defaults.locale.enable = mkDefault true;
|
ataraxia.defaults.locale.enable = mkDefault true;
|
||||||
ataraxia.defaults.lix.enable = mkDefault true;
|
ataraxia.defaults.lix.enable = mkDefault true;
|
||||||
ataraxia.defaults.nix.enable = mkDefault true;
|
ataraxia.defaults.nix.enable = mkDefault true;
|
||||||
@ -65,6 +66,7 @@ in
|
|||||||
time.timeZone = "Etc/UTC";
|
time.timeZone = "Etc/UTC";
|
||||||
};
|
};
|
||||||
desktopRole = recursiveUpdate baseRole {
|
desktopRole = recursiveUpdate baseRole {
|
||||||
|
ataraxia.defaults.hardware.graphics = mkDefault true;
|
||||||
ataraxia.defaults.sound.enable = mkDefault true;
|
ataraxia.defaults.sound.enable = mkDefault true;
|
||||||
|
|
||||||
location = {
|
location = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user