diff --git a/README.org b/README.org index 96d1dfb..fa45c37 100644 --- a/README.org +++ b/README.org @@ -65,10 +65,14 @@ #+END_SRC 7. Install nixos! #+BEGIN_SRC bash - sudo nixos-install --impure --root /mnt --flake .#reykjavik + sudo nixos-install --impure --root /mnt --flake '.#reykjavik' #+END_SRC 8. 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 +* Rebuilding + #+BEGIN_SRC bash + sudo nixos-rebuild switch --impure --flake '.#reykjavik' + #+END_SRC diff --git a/hosts/kopavogur/default.nix b/hosts/kopavogur/default.nix index 6a356d1..ffcf442 100644 --- a/hosts/kopavogur/default.nix +++ b/hosts/kopavogur/default.nix @@ -29,7 +29,6 @@ desktop = { enable = true; laptop = true; - }; # - Editors and development ------------------ diff --git a/hosts/reykjavik/default.nix b/hosts/reykjavik/default.nix index 3eb0af8..3b9a95a 100644 --- a/hosts/reykjavik/default.nix +++ b/hosts/reykjavik/default.nix @@ -3,7 +3,6 @@ { imports = [ ./hardware.nix - ./nvidia.nix ]; # - Basic -------------------------------------- @@ -24,12 +23,16 @@ # - System ----------------------------------- system.bluetooth.enable = true; + system.nvidia = { + enable = true; + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:1:0:0"; + }; # - Desktop ---------------------------------- desktop = { enable = true; laptop = true; - }; # - Editors and development ------------------ diff --git a/hosts/reykjavik/nvidia.nix b/hosts/reykjavik/nvidia.nix deleted file mode 100644 index d29113d..0000000 --- a/hosts/reykjavik/nvidia.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ 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/modules/system/nvidia.nix b/modules/system/nvidia.nix new file mode 100644 index 0000000..cad3fb6 --- /dev/null +++ b/modules/system/nvidia.nix @@ -0,0 +1,39 @@ +{ config, pkgs, lib, ... }: + +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 "$@" + ''; + cfg = config.samfelag.modules.system.nvidia; +in +{ + options.samfelag.modules.system.nvidia = { + enable = lib.mkEnableOption "nvidia"; + + intelBusId = lib.mkOption { type = lib.types.str; }; + nvidiaBusId = lib.mkOption { type = lib.types.str; }; + }; + + config = lib.mkIf cfg.enable { + 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 = cfg.intelBusId; + + # Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA + nvidiaBusId = cfg.nvidiaBusId; + }; + }; +}