Skip to content

Commit

Permalink
WIP: fix(easyNvidia?): Make prime offload work on sway
Browse files Browse the repository at this point in the history
Turns out that:

- The usual env variables make everything use nvidia even if it
  shouldn't (duh)
- To use a non-default GPU on wlroots, use `$WLR_DRM_DEVICES`
  - On my current testbed the default GPU happens to be nvidia, see
    sway docs on how to handle this elsewhere
- Using unstable nixpkgs in nixpkgs-wayland can cause issues with
  drivers

Still need to confirm if the addition of `"amdgpu"` to the
`videoDrivers` list is actually necessary, and figure out how to
ensure that powermanagement is actually turned on, see #383.

*Then* set up a good offload script, also see #383 for hints.
  • Loading branch information
tlater-famedly committed Feb 5, 2025
1 parent 40c1ab2 commit e5626bb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
22 changes: 4 additions & 18 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
inputs.nixpkgs.follows = "nixpkgs";
};

nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland";
nixpkgs-wayland = {
url = "github:nix-community/nixpkgs-wayland";
inputs.nixpkgs.follows = "nixpkgs";
};

nix-gaming = {
url = "github:fufexan/nix-gaming";
Expand Down
10 changes: 10 additions & 0 deletions nixos-config/hosts/rin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
amdgpuBusId = "PCI:5:0:0";
};

services.xserver.videoDrivers = [ "amdgpu" ];

environment.variables = {
# For wlroots, order the AMD card *before* the NVIDIA card.
#
# In practice, this assignment is probably not static; see the
# sway wiki for some udev hacks to resolve this.
WLR_DRM_DEVICES = "/dev/dri/card2:/dev/dri/card1";
};

networking = {
hostName = "rin";
hostId = "e6aaf496";
Expand Down
2 changes: 1 addition & 1 deletion nixos-modules/nvidia/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ in
];
};

environment.variables = {
environment.variables = lib.mkIf (!cfg.offload.enable) {
# Required to run the correct GBM backend for nvidia GPUs on wayland
GBM_BACKEND = "nvidia-drm";
# Apparently, without this nouveau may attempt to be used instead
Expand Down

0 comments on commit e5626bb

Please sign in to comment.