Move nvidia to a module
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
desktop = {
|
||||
enable = true;
|
||||
laptop = true;
|
||||
|
||||
};
|
||||
|
||||
# - Editors and development ------------------
|
||||
|
||||
@@ -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 ------------------
|
||||
|
||||
@@ -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";
|
||||
};
|
||||
}
|
||||
39
modules/system/nvidia.nix
Normal file
39
modules/system/nvidia.nix
Normal file
@@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user