From 0f4b895d38f05f264471d0c34b6df681cba3ff75 Mon Sep 17 00:00:00 2001 From: marc Date: Fri, 4 Nov 2022 19:32:53 +0100 Subject: [PATCH] Added nvidia drivers and gaming profile --- README.org | 6 ++++++ flake.nix | 1 + home/hosts/reykjavik.nix | 1 + home/profiles/default.nix | 1 + home/profiles/gaming.nix | 24 ++++++++++++++++++++++++ system/hosts/reykjavik/default.nix | 10 +++++++--- system/hosts/reykjavik/nvidia.nix | 29 +++++++++++++++++++++++++++++ system/profiles/default.nix | 1 + system/profiles/gaming.nix | 19 +++++++++++++++++++ 9 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 home/profiles/gaming.nix create mode 100644 system/hosts/reykjavik/nvidia.nix create mode 100644 system/profiles/gaming.nix diff --git a/README.org b/README.org index 87632c7..1fb58cb 100644 --- a/README.org +++ b/README.org @@ -85,3 +85,9 @@ nixos-generate-config --dir <> --no-filesystems #+BEGIN_SRC bash sudo nixos-install --impure --root /mnt --flake .#reykjavik #+END_SRC + +1. Set up the user +You'll set the root password during the installation. You can then reboot and use the installed OS. First thing you'll have to do is log in as root and set the password for your user: +#+BEGIN_SRC bash +passwd marc +#+END_SRC diff --git a/flake.nix b/flake.nix index f6dd3ba..9a91894 100644 --- a/flake.nix +++ b/flake.nix @@ -51,6 +51,7 @@ # - Reykjavik ---------------------------- reykjavik = lib.nixosSystem { inherit system; + inherit pkgs; modules = [ ./system/modules diff --git a/home/hosts/reykjavik.nix b/home/hosts/reykjavik.nix index f92b9b8..0a523c8 100644 --- a/home/hosts/reykjavik.nix +++ b/home/hosts/reykjavik.nix @@ -6,6 +6,7 @@ samfelag = { profiles = { desktop.enable = true; + gaming.enable = true; }; }; } diff --git a/home/profiles/default.nix b/home/profiles/default.nix index 29c8469..29942d5 100644 --- a/home/profiles/default.nix +++ b/home/profiles/default.nix @@ -4,5 +4,6 @@ imports = [ ./common.nix ./desktop.nix + ./gaming.nix ]; } diff --git a/home/profiles/gaming.nix b/home/profiles/gaming.nix new file mode 100644 index 0000000..bf85332 --- /dev/null +++ b/home/profiles/gaming.nix @@ -0,0 +1,24 @@ +{ config, lib, pkgs, ... }: + +with lib; +let + cfg = config.samfelag.profiles.gaming; +in +{ + options.samfelag.profiles.gaming = { + enable = mkEnableOption "gaming profile"; + }; + + config = mkIf cfg.enable { + + # - Dependencies ----------------------------- + + samfelag.modules = { + }; + + home.packages = with pkgs; [ + lutris + ]; + + }; +} diff --git a/system/hosts/reykjavik/default.nix b/system/hosts/reykjavik/default.nix index b422d23..12b0988 100644 --- a/system/hosts/reykjavik/default.nix +++ b/system/hosts/reykjavik/default.nix @@ -3,6 +3,7 @@ { imports = [ ./hardware.nix + ./nvidia.nix ]; # - Basic -------------------------------------- @@ -19,9 +20,12 @@ # - Services ----------------------------------- - samfelag.profiles.desktop = { - enable = true; - laptop = true; + samfelag.profiles = { + desktop = { + enable = true; + laptop = true; + }; + gaming.enable = true; }; system.stateVersion = "22.05"; diff --git a/system/hosts/reykjavik/nvidia.nix b/system/hosts/reykjavik/nvidia.nix new file mode 100644 index 0000000..d29113d --- /dev/null +++ b/system/hosts/reykjavik/nvidia.nix @@ -0,0 +1,29 @@ +{ config, pkgs, ... }: + +let + nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" '' + export __NV_PRIME_RENDER_OFFLOAD=1 + export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 + export __GLX_VENDOR_LIBRARY_NAME=nvidia + export __VK_LAYER_NV_optimus=NVIDIA_only + exec "$@" + ''; +in +{ + environment.systemPackages = [ nvidia-offload ]; + + services.xserver.videoDrivers = [ "nvidia" ]; + + hardware.opengl.enable = true; + hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable; + + hardware.nvidia.prime = { + offload.enable = true; + + # Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA + intelBusId = "PCI:0:2:0"; + + # Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA + nvidiaBusId = "PCI:1:0:0"; + }; +} diff --git a/system/profiles/default.nix b/system/profiles/default.nix index 29c8469..29942d5 100644 --- a/system/profiles/default.nix +++ b/system/profiles/default.nix @@ -4,5 +4,6 @@ imports = [ ./common.nix ./desktop.nix + ./gaming.nix ]; } diff --git a/system/profiles/gaming.nix b/system/profiles/gaming.nix new file mode 100644 index 0000000..7f925e4 --- /dev/null +++ b/system/profiles/gaming.nix @@ -0,0 +1,19 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.samfelag.profiles.gaming; +in +{ + options.samfelag.profiles.gaming = { + + enable = lib.mkEnableOption "gaming profile"; + }; + + config = lib.mkIf cfg.enable { + programs.steam = { + enable = true; + remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play + dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server + }; + }; +}