From d224d55c1ad6d0705f55b3030fa636ecabd5f92b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 12 Nov 2024 19:41:27 +0000 Subject: [PATCH] add nvidia and prime to citadel --- hosts/citadel/default.nix | 61 +++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/hosts/citadel/default.nix b/hosts/citadel/default.nix index 2daabc8..24fc4fd 100644 --- a/hosts/citadel/default.nix +++ b/hosts/citadel/default.nix @@ -71,10 +71,12 @@ in { }; }; - swapDevices = [ { - device = "/.swapvol/swapfile"; - size = 32*1024; - } ]; + swapDevices = [ + { + device = "/.swapvol/swapfile"; + size = 32 * 1024; + } + ]; services = { libinput.touchpad.accelSpeed = "0.5"; @@ -82,14 +84,14 @@ in { xkb.options = "caps:swapescape"; dpi = 196; upscaleDefaultCursor = true; - # FIXME this doesnt work for some reason - # displayManager.sessionCommands = pkgs.writeShellScriptBin "key-remaps" '' - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 64 = Mode_switch" - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 43 = h H Left H" - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 44 = j J Down J" - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 45 = k K Up K" - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 46 = l L Right L" - # ''; + # FIXME this doesnt work for some reason + # displayManager.sessionCommands = pkgs.writeShellScriptBin "key-remaps" '' + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 64 = Mode_switch" + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 43 = h H Left H" + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 44 = j J Down J" + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 45 = k K Up K" + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 46 = l L Right L" + # ''; }; }; @@ -123,6 +125,41 @@ in { ]; }; + # nvidia + hardware.opengl = { + enable = true; + }; + + services.xserver.videoDrivers = ["nvidia"]; + + hardware.nvidia = { + prime = { + offload = { + enable = true; + enableOffloadCmd = true; + }; + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + modesetting.enable = true; + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; + nvidiaSettings = true; + # FIXME issue with stable nvidia driver and latest linux kernel + # use mkDriver to specify newer nvidia driver that is compatible + # see: https://github.com/NixOS/nixpkgs/issues/341844#issuecomment-2351075413 + # and https://discourse.nixos.org/t/builder-for-nvidia-x11-550-78-6-10-drv-failed-with-exit-code-2/49360/32 + package = config.boot.kernelPackages.nvidiaPackages.mkDriver { + version = "555.58.02"; + sha256_64bit = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM="; + sha256_aarch64 = "sha256-wb20isMrRg8PeQBU96lWJzBMkjfySAUaqt4EgZnhyF8="; + openSha256 = "sha256-8hyRiGB+m2hL3c9MDA/Pon+Xl6E788MZ50WrrAGUVuY="; + settingsSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8="; + persistencedSha256 = "sha256-a1D7ZZmcKFWfPjjH1REqPM5j/YLWKnbkP9qfRyIyxAw="; + }; + }; + networking = { hostName = "citadel"; networkmanager.enable = true;