Skip to content

Commit

Permalink
Set up PRIME Offload & VA-API + Add firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
hzmmohamed committed Jan 12, 2024
1 parent 7a87500 commit 2eddf93
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 3 deletions.
3 changes: 1 addition & 2 deletions modules/nixos/desktop/sway/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ in {
];
services.swayidle = {enable = true;};
programs.swaylock.enable = true;
services.swayr = {
programs.swayr = {
enable = true;
systemd.enable = true;
settings = {
Expand All @@ -76,7 +76,6 @@ in {
};
};


wayland.windowManager.sway = {
enable = true;

Expand Down
79 changes: 79 additions & 0 deletions modules/nixos/hardware/nvidia/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
options,
config,
pkgs,
lib,
...
}:
with lib;
with lib.plusultra; let
cfg = config.caramelmint.hardware.nvidia;
in {
options.caramelmint.hardware.nvidia = with types; {
enable =
mkBoolOpt false
"Whether or not to enable and configure NVIDIA dGPU support.";
};

config = mkIf cfg.enable {
# Enable OpenGL
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};

# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = ["nvidia"];

hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;

prime = {
# Make sure to use the correct Bus ID values for your system!
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";

# Enable PRIME Offload
offload = {
enable = true;
enableOffloadCmd = true;
};
};

# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
powerManagement.enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;

# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;

# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;

# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.stable;
};

# specialisation = {
# on-the-go.configuration = {
# system.nixos.tags = ["on-the-go"];
# hardware.nvidia = {
# prime.offload.enable = lib.mkForce true;
# prime.offload.enableOffloadCmd = lib.mkForce true;
# prime.sync.enable = lib.mkForce false;
# };
# };
# };
};
}
2 changes: 2 additions & 0 deletions modules/nixos/suites/games/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ in {
mesa_drivers
intel-ocl
beignet
intel-media-driver
nvidia-vaapi-driver
vaapiIntel
vaapiVdpau
libvdpau-va-gl
Expand Down
4 changes: 4 additions & 0 deletions modules/nixos/suites/office/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ in {
programs = {
chromium = {
enable = true;
package = pkgs.unstable.chromium;
extensions = [
{id = "nngceckbapebfimnlniiiahkandclblb";} # Bitwarden
{id = "chphlpgkkbolifaimnlloiipkdnihall";} # OneTab
Expand All @@ -60,6 +61,9 @@ in {
{id = "fpnmgdkabkmnadcjpehmlllkndpkmiak";} # Wayback Machine
];
};
firefox = {
enable=true;
};
};

home.packages = with pkgs; [
Expand Down
2 changes: 1 addition & 1 deletion modules/nixos/system/boot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ in {
# Kernel
kernelParams = ["i915.force_probe=46a6"];
blacklistedKernelModules = [
"nouveau"
# "nouveau"
# "intel_lpss_pci"
];
};
Expand Down
5 changes: 5 additions & 0 deletions systems/x86_64-linux/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ with lib.plusultra; {
media = enabled;
games = enabled;
};


hardware = {
nvidia = enabled;
};
system.power = enabled;
};

Expand Down

0 comments on commit 2eddf93

Please sign in to comment.