diff --git a/default.nix b/default.nix index 49f01291..4a88aabc 100644 --- a/default.nix +++ b/default.nix @@ -10,6 +10,7 @@ # add entry to module's default.nix outputs.nixosModules.desktop outputs.nixosModules.shell + outputs.nixosModules.hardware ]; # flakes diff --git a/hosts/sakotop/configuration.nix b/hosts/sakotop/configuration.nix index d3955377..f1d3d471 100644 --- a/hosts/sakotop/configuration.nix +++ b/hosts/sakotop/configuration.nix @@ -24,6 +24,9 @@ kitty.enable = true; bspwm.enable = true; }; + hardware = { + nvidia.enable = true; + }; shell = { nix = { # makes nix search nixpkgs @@ -33,39 +36,6 @@ }; }; - # Nvidia Drivers - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - - # tell xserver i want this driver - services.xserver.videoDrivers = ["nvidia"]; - - hardware.nvidia = { - # wayland support cause why not - modesetting.enable = true; - - # TODO(sako):: add this as a cfg option for hosts - open = false; - - # settings - nvidiaSettings = true; - - # Package - package = config.boot.kernelPackages.nvidiaPackages.stable; - - prime = { - offload = { - enable = true; - enableOffloadCmd = true; - }; - intelBusId = "PCI:0:2:0"; - nvidiaBusId = "PCI:1:0:0"; - }; - }; - # Bluetooth hardware.bluetooth = { enable = true; diff --git a/modules/default.nix b/modules/default.nix index f973b691..1e8f5986 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,4 +1,5 @@ { desktop = import ./desktop; shell = import ./shell; + hardware = import ./hardware; } diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix new file mode 100644 index 00000000..efa08338 --- /dev/null +++ b/modules/hardware/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./nvidia + ]; +} diff --git a/modules/hardware/nvidia/default.nix b/modules/hardware/nvidia/default.nix new file mode 100644 index 00000000..285248b4 --- /dev/null +++ b/modules/hardware/nvidia/default.nix @@ -0,0 +1,46 @@ +{ outputs, options, config, lib, pkgs, ...}: +with lib; +let + cfg = config.modules.hardware.nvidia; +in +{ + options.modules.hardware.nvidia = { + enable = mkEnableOption false; + }; + + config = mkIf cfg.enable { + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + + services.xserver.videoDrivers = [ "nvidia" ]; + + hardware.nvidia = { + # wayland support + modesetting.enable = true; + + # TODO(sako) add this as a cfg option + # set to true if you have an rtx or newer graphics card + # else set to false + open = false; + + # settings + nvidiaSettings = true; + + # Package + package = config.boot.kernelPackages.nvidiaPackages.stable; + + # TODO(sako) ALSO add these as a cfg option + prime = { + offload = { + enable = true; + enableOffloadCmd = true; + }; + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + }; + }; +}