feat(modules/hardware/nvidia): add nvidia configuration

This commit is contained in:
Mohammad Rafiq 2025-05-18 15:10:57 +08:00
parent 2cd82e2e2a
commit 62f94ad85e
3 changed files with 30 additions and 6 deletions

View file

@ -2,14 +2,21 @@
{
imports = [
./btrfs.nix
./nvidia.nix
];
options = {
hardware.drives.btrfs.enable = lib.mkEnableOption "";
hardware.drives.btrfs.drive = lib.mkOption {
options.hardware = {
drives.btrfs = {
enable = lib.mkEnableOption "";
drive = lib.mkOption {
type = lib.types.str;
default = "";
};
ephemeralRoot = lib.mkEnableOption "";
};
gpu = lib.mkOption {
type = lib.types.str;
default = "";
};
hardware.drives.btrfs.ephemeralRoot = lib.mkEnableOption "";
default = "";
};
};
}

View file

@ -0,0 +1,16 @@
{ lib, config, pkgs, ... }:
{
config = lib.mkIf (config.hardware.gpu == "nvidia") (lib.mkMerge [
{
#TODO: Setup CUDA
hardware.graphics.enable = true;
hardware.graphics.extraPackages = with pkgs; [
nvidia-vaapi-driver
];
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia.open = true;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest;
nixpkgs.config.allowUnfree = true;
}
]);
}

View file

@ -5,6 +5,7 @@
drive = "/dev/disk/by-id/nvme-CT2000P3SSD8_2325E6E77434";
ephemeralRoot = true;
};
hardware.gpu = "nvidia";
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ "dm-snapshot" ];