This commit is contained in:
Andreas Schaafsma 2025-06-06 01:36:55 +02:00
parent 7d07de663d
commit ce387ab5db
6 changed files with 274 additions and 97 deletions

150
flake.lock generated
View File

@ -34,11 +34,11 @@
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1717312683,
"narHash": "sha256-FrlieJH50AuvagamEvWMIE6D2OAnERuDboFDYAED/dE=",
"lastModified": 1746162366,
"narHash": "sha256-5SSSZ/oQkwfcAz/o/6TlejlVGqeK08wyREBQ5qFFPhM=",
"owner": "nix-community",
"repo": "flake-compat",
"rev": "38fd3954cf65ce6faf3d0d45cd26059e059f07ea",
"rev": "0f158086a2ecdbb138cd0429410e44994f1b7e4b",
"type": "github"
},
"original": {
@ -105,11 +105,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
@ -120,7 +120,7 @@
},
"flake-utils-plus": {
"inputs": {
"flake-utils": "flake-utils_2"
"flake-utils": "flake-utils"
},
"locked": {
"lastModified": 1715533576,
@ -137,24 +137,6 @@
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"game-of-life": {
"inputs": {
"nixpkgs": "nixpkgs"
@ -202,11 +184,32 @@
]
},
"locked": {
"lastModified": 1735381016,
"narHash": "sha256-CyCZFhMUkuYbSD6bxB/r43EdmDE7hYeZZPTCv0GudO4=",
"lastModified": 1748668774,
"narHash": "sha256-fYk/vk4ClmvHIgnGv/5GNRiDLtNCwXo9aLq36L/x+P4=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "10e99c43cdf4a0713b4e81d90691d22c6a58bdf2",
"rev": "60e4624302d956fe94d3f7d96a560d14d70591b9",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"home-manager_2": {
"inputs": {
"nixpkgs": [
"zen-browser",
"nixpkgs"
]
},
"locked": {
"lastModified": 1743604125,
"narHash": "sha256-ZD61DNbsBt1mQbinAaaEqKaJk2RFo9R/j+eYWeGMx7A=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "180fd43eea296e62ae68e079fcf56aba268b9a1a",
"type": "github"
},
"original": {
@ -249,11 +252,11 @@
"rust-overlay": "rust-overlay_2"
},
"locked": {
"lastModified": 1735608992,
"narHash": "sha256-NkzMjar9Sz0pLJxVfp9Hchf48YCuQQ1AnGVYGNfzwVA=",
"lastModified": 1748697856,
"narHash": "sha256-RiPbZm8NbbCXVPi6WZDWabGpOA6X98nSk0GPTaPlmVA=",
"owner": "lilyinstarlight",
"repo": "nixos-cosmic",
"rev": "af6900c2f6e68439c5f4aaaa8bb1a6d54bf04025",
"rev": "a0b5cb4cf16f0a5f90e3b683b6be50f39ea407bf",
"type": "github"
},
"original": {
@ -265,15 +268,14 @@
"nixos-wsl": {
"inputs": {
"flake-compat": "flake-compat_3",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1733854371,
"narHash": "sha256-K9qGHniYBbjqVcEiwXyiofj/IFf78L5F0/FCf+CKyr0=",
"lastModified": 1746453552,
"narHash": "sha256-r66UGha+7KVHkI7ksrcMjnw/mm9Sg4l5bQlylxHwdGU=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "dee4425dcee3149475ead0cb6a616b8a028c5888",
"rev": "be618645aa0adf461f778500172b6896d5ab2d01",
"type": "github"
},
"original": {
@ -317,11 +319,11 @@
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1735531152,
"narHash": "sha256-As8I+ebItDKtboWgDXYZSIjGlKeqiLBvjxsQHUmAf1Q=",
"lastModified": 1748421225,
"narHash": "sha256-XXILOc80tvlvEQgYpYFnze8MkQQmp3eQxFbTzb3m/R0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3ffbbdbac0566a0977da3d2657b89cbcfe9a173b",
"rev": "78add7b7abb61689e34fc23070a8f55e1d26185b",
"type": "github"
},
"original": {
@ -333,11 +335,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1735471104,
"narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=",
"lastModified": 1748460289,
"narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4",
"rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102",
"type": "github"
},
"original": {
@ -349,27 +351,27 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1733384649,
"narHash": "sha256-K5DJ2LpPqht7K76bsxetI+YHhGGRyVteTPRQaIIKJpw=",
"lastModified": 1742937945,
"narHash": "sha256-lWc+79eZRyvHp/SqMhHTMzZVhpxkRvthsP1Qx6UCq0E=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "190c31a89e5eec80dd6604d7f9e5af3802a58a13",
"rev": "d02d88f8de5b882ccdde0465d8fa2db3aa1169f7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1735471104,
"narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=",
"lastModified": 1748460289,
"narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4",
"rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102",
"type": "github"
},
"original": {
@ -381,11 +383,11 @@
},
"nixpkgs_5": {
"locked": {
"lastModified": 1727348695,
"narHash": "sha256-J+PeFKSDV+pHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI=",
"lastModified": 1743448293,
"narHash": "sha256-bmEPmSjJakAp/JojZRrUvNcDX2R5/nuX6bm+seVaGhs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1925c603f17fc89f4c8f6bf6f631a802ad85d784",
"rev": "77b584d61ff80b4cef9245829a6f1dfad5afdfa3",
"type": "github"
},
"original": {
@ -465,11 +467,11 @@
]
},
"locked": {
"lastModified": 1735525800,
"narHash": "sha256-pcN8LAL021zdC99a9F7iEiFCI1wmrE4DpIYUgKpB/jY=",
"lastModified": 1748658947,
"narHash": "sha256-F+nGITu6D7RswJlm8qCuU1PCuOSgDeAqaDKWW1n1jmQ=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "10faa81b4c0135a04716cbd1649260d82b2890cd",
"rev": "fc82ce758cc5df6a6d5d24e75710321cdbdc787a",
"type": "github"
},
"original": {
@ -487,11 +489,11 @@
]
},
"locked": {
"lastModified": 1732544274,
"narHash": "sha256-qvzLIxuqukl0nxpXHEh5+iw1BLeLxYOwRC0+7cFUbPo=",
"lastModified": 1736130495,
"narHash": "sha256-4i9nAJEZFv7vZMmrE0YG55I3Ggrtfo5/T07JEpEZ/RM=",
"owner": "snowfallorg",
"repo": "lib",
"rev": "cfeacd055545ab5de0ecfd41e09324dcd8fb2bbb",
"rev": "02d941739f98a09e81f3d2d9b3ab08918958beac",
"type": "github"
},
"original": {
@ -507,11 +509,11 @@
]
},
"locked": {
"lastModified": 1735468296,
"narHash": "sha256-ZjUjbvS06jf4fElOF4ve8EHjbpbRVHHypStoY8HGzk8=",
"lastModified": 1747603214,
"narHash": "sha256-lAblXm0VwifYCJ/ILPXJwlz0qNY07DDYdLD+9H+Wc8o=",
"owner": "mic92",
"repo": "sops-nix",
"rev": "bcb8b65aa596866eb7e5c3e1a6cccbf5d1560b27",
"rev": "8d215e1c981be3aa37e47aeabd4e61bb069548fd",
"type": "github"
},
"original": {
@ -535,28 +537,13 @@
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"trilium-next-pr": {
"locked": {
"lastModified": 1733744893,
"narHash": "sha256-CufsQ+I/s7TsPd6Rq62WAQZQDtoeC8nw+ExuXeWnDRk=",
"lastModified": 1736678965,
"narHash": "sha256-2A687i3Rq0/wqJVvpgaiRPWcfnBBuBhPjKaT8cnd7o0=",
"owner": "FliegendeWurst",
"repo": "nixpkgs",
"rev": "6000de6a3f96f729ef031cbd4ecb04898cb38780",
"rev": "4fcdf706929246476e52e960760b6643cb8395c4",
"type": "github"
},
"original": {
@ -568,14 +555,15 @@
},
"zen-browser": {
"inputs": {
"home-manager": "home-manager_2",
"nixpkgs": "nixpkgs_5"
},
"locked": {
"lastModified": 1736824652,
"narHash": "sha256-8J56ngRvKVvCxdY3iDtol/9UAJfwCh0k96DnyNchUCA=",
"lastModified": 1748675871,
"narHash": "sha256-t8kG9ZluGH3DNHtG5M196LdPgJdM2Qb8kgWi0iBKtQ0=",
"owner": "0xc000022070",
"repo": "zen-browser-flake",
"rev": "a17923b5fd758700c67afdaae2a1d3123381f96b",
"rev": "6205ec7c9c5e1fe8eac7b1af251c97a7cbef7c4e",
"type": "github"
},
"original": {

View File

@ -18,6 +18,41 @@ in
# Enable NVIDIA driver for X11 and Wayland
services.xserver.videoDrivers = [ "amdgpu" "nvidia" ];
services.xserver.displayManager.xserverArgs = [ "-config" "/opt/x11/xserver.conf" ];
services.xserver.config = lib.mkAfter ''
Section "ServerLayout"
Identifier "layout"
Screen 0 "amdgpu"
Inactive "nvidia"
Option "AllowNVIDIAGPUScreens"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:01:0:0"
EndSection
Section "Screen"
Identifier "nvidia"
Device "nvidia"
EndSection
Section "Device"
Identifier "amdgpu"
Driver "amdgpu"
BusID "PCI:50:0:0"
EndSection
Section "Screen"
Identifier "amdgpu"
Device "amdgpu"
EndSection
'';
services.switcherooControl.enable = true;
# Enable OpenGL
hardware.graphics = {
enable = true;
@ -25,7 +60,7 @@ in
};
# Use Beta Driver Package
boot.extraModulePackages = [ config.boot.kernelPackages.nvidia_x11_beta ];
boot.extraModulePackages = [ config.boot.kernelPackages.nvidia_x11 ];
@ -33,22 +68,22 @@ in
# Enable required Kernel Modules
boot.initrd.kernelModules = [
"amdgpu"
"nvidia-modeset"
"nvidia"
# "nvidia-drm"
"nvidiafb"
# "amdgpu"
"nvidia-drm"
# "nvidiafb"
# "nvidia-uvm"
# "nvidia-modeset"
# "i2c-nvidia_gpu"
];
boot.kernelParams = [
"amdgpu.modeset=1"
# "amdgpu.modeset=1"
"nvidia-drm.fbdev=1"
"nvidia-drm.modeset=0"
"nvidia-drm.modeset=1"
# "nvidia.NVreg_PreserveVideoMemoryAllocations=0"
"amd_iommu=on"
# "amd_iommu=on"
# "vfio-pci.ids=\"10de:2489,10de:228b\""
# "nomodeset"
# "nvidia_drm.modeset=1"
@ -102,7 +137,8 @@ in
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.beta;
# package = config.boot.kernelPackages.nvidiaPackages.beta;
package = config.boot.kernelPackages.nvidiaPackages.stable;
# package = config.boot.kernelPackages.nvidiaPackages.none;
# package = config.boot.kernelPackages.nvidiaPackages.production;
@ -110,10 +146,12 @@ in
prime = {
offload = {
enable = true;
enableOffloadCmd = true;
enable = lib.mkForce true;
enableOffloadCmd = lib.mkForce true;
};
reverseSync.enable = false;
reverseSync.enable = lib.mkForce false;
sync.enable = lib.mkForce false;
# Make sure to use the correct Bus ID values for your system!
# intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:01:0:0";
@ -128,4 +166,5 @@ in
};
};
}

View File

@ -0,0 +1,149 @@
{ config, lib, pkgs, modulesPath, ... }:
let
inherit (lib) mkEnableOption mkIf;
inherit (lib.my-namespace) disabled enabled;
cfg = config.my-namespace.hardware.graphics-nvidia-specializations;
in
{
options.my-namespace.hardware.graphics-nvidia-specializations = {
enable = mkEnableOption "Enable nvidia";
};
options.nvidia-sync.enable = lib.mkEnableOption "Enable NVIDIA prime sync mode";
options.nvidia-offload.enable = lib.mkEnableOption "Enable NVIDIA prime sync mode";
config = {
specialisation."NVIDIA-SYNC".configuration = {
system.nixos.tags = [ "with-nvidia-sync" ];
nvidia-sync.enable = true;
};
specialisation."NVIDIA-OFFLOAD".configuration = {
system.nixos.tags = [ "with-nvidia-offload" ];
nvidia-offload.enable = true;
};
services.xserver.videoDrivers = [ "nvidia" "amdgpu" ];
hardware.graphics = {
extraPackages = with pkgs; [ nvidia-vaapi-driver ];
};
boot.kernelParams = [
"nvidia.NVreg_PreserveVideoMemoryAllocations=1"
"nvidia-drm.fbdev=1"
"nvidia-drm.modeset=1"
"amdgpu.modeset=0"
];
boot.initrd.kernelModules = [
# "amdgpu"
"nvidia"
"nvidia-drm"
"nvidiafb"
# "nvidia-uvm"
# "nvidia-modeset"
# "i2c-nvidia_gpu"
];
hardware.nvidia = {
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
powerManagement.enable = config.nvidia-offload.enable;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
# package = config.boot.kernelPackages.nvidiaPackages.beta;
package = config.boot.kernelPackages.nvidiaPackages.production;
prime = {
amdgpuBusId = "PCI:50:0:0";
nvidiaBusId = "PCI:1:0:0";
} // lib.optionalAttrs config.nvidia-sync.enable {
sync.enable = true;
} // lib.optionalAttrs (config.nvidia-offload.enable) {
offload = {
enable = true;
enableOffloadCmd = true;
};
};
};
services.xserver.config = lib.mkAfter ''
Section "ServerLayout"
Identifier "layout"
Screen 0 "amdgpu"
Inactive "nvidia"
Option "AllowNVIDIAGPUScreens"
Option "AllowEmptyInitialConfiguration" "True"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:01:0:0"
Option "AllowEmptyInitialConfiguration" "True"
EndSection
Section "Screen"
Identifier "nvidia"
Device "nvidia"
Option "AllowEmptyInitialConfiguration" "True"
EndSection
Section "Device"
Identifier "amdgpu"
Driver "amdgpu"
BusID "PCI:50:0:0"
Option "AllowEmptyInitialConfiguration" "True"
EndSection
Section "Screen"
Identifier "amdgpu"
Device "amdgpu"
Option "AllowEmptyInitialConfiguration" "True"
EndSection
'';
# services.xserver.config = lib.mkForce ''
# Section "ServerLayout"
# Identifier "layout"
# Screen 0 "amdgpu"
# Inactive "nvidia"
# Option "AllowNVIDIAGPUScreens"
# EndSection
# Section "Device"
# Identifier "nvidia"
# Driver "nvidia"
# BusID "PCI:01:0:0"
# EndSection
# Section "Screen"
# Identifier "nvidia"
# Device "nvidia"
# EndSection
# Section "Device"
# Identifier "amdgpu"
# Driver "amdgpu"
# BusID "PCI:50:0:0"
# EndSection
# Section "Screen"
# Identifier "amdgpu"
# Device "amdgpu"
# EndSection
# '';
};
}

View File

@ -43,7 +43,7 @@
};
services = {
displayManager.sddm.enable = false;
displayManager.sddm.enable = true;
displayManager.defaultSession = "gnome";
desktopManager.plasma6.enable = true;
xserver = {
@ -98,7 +98,7 @@
};
# Configure Display Manager
displayManager = {
gdm.enable = true;
gdm.enable = false;
# Enable lightdm
lightdm.enable = false;
};

View File

@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
{
boot.kernelParams = [ "drm.edid_firmware=DP-6:edid/edid.bin" ];
boot.kernelParams = [ "drm.edid_firmware=DP-1:edid/edid.bin,DP-2:edid/edid.bin,DP-3:edid/edid.bin,DP-4:edid/edid.bin" ];
hardware.firmware = [
(

View File

@ -4,7 +4,8 @@ let
in
{
my-namespace.hardware = {
graphics-nvidia-prime-amd = enabled;
graphics-nvidia-specializations = enabled;
# graphics-nvidia-prime-amd = enabled;
# graphics-nvidia-prime-amd-testing = enabled;
# graphics-amd-igpu-only = enabled;
};