nixos/nvidia: run nixfmt on nvidia related files

+478 -344
+34 -24
nixos/modules/hardware/video/nvidia.nix
··· 92 92 information, see the NVIDIA docs, on Chapter 23. Dynamic Boost on Linux 93 93 ''; 94 94 95 - modesetting.enable = lib.mkEnableOption '' 96 - kernel modesetting when using the NVIDIA proprietary driver. 95 + modesetting.enable = 96 + lib.mkEnableOption '' 97 + kernel modesetting when using the NVIDIA proprietary driver. 97 98 98 - Enabling this fixes screen tearing when using Optimus via PRIME (see 99 - {option}`hardware.nvidia.prime.sync.enable`. This is not enabled 100 - by default because it is not officially supported by NVIDIA and would not 101 - work with SLI. 99 + Enabling this fixes screen tearing when using Optimus via PRIME (see 100 + {option}`hardware.nvidia.prime.sync.enable`. This is not enabled 101 + by default because it is not officially supported by NVIDIA and would not 102 + work with SLI. 102 103 103 - Enabling this and using version 545 or newer of the proprietary NVIDIA 104 - driver causes it to provide its own framebuffer device, which can cause 105 - Wayland compositors to work when they otherwise wouldn't. 106 - '' // { 107 - default = lib.versionAtLeast cfg.package.version "535"; 108 - defaultText = lib.literalExpression "lib.versionAtLeast cfg.package.version \"535\""; 109 - }; 104 + Enabling this and using version 545 or newer of the proprietary NVIDIA 105 + driver causes it to provide its own framebuffer device, which can cause 106 + Wayland compositors to work when they otherwise wouldn't. 107 + '' 108 + // { 109 + default = lib.versionAtLeast cfg.package.version "535"; 110 + defaultText = lib.literalExpression "lib.versionAtLeast cfg.package.version \"535\""; 111 + }; 110 112 111 113 prime.nvidiaBusId = lib.mkOption { 112 114 type = busIDType; ··· 266 268 ''; 267 269 }; 268 270 269 - gsp.enable = lib.mkEnableOption '' 270 - the GPU System Processor (GSP) on the video card 271 - '' // { 272 - default = useOpenModules || lib.versionAtLeast nvidia_x11.version "555"; 273 - defaultText = lib.literalExpression '' 274 - config.hardware.nvidia.open == true || lib.versionAtLeast config.hardware.nvidia.package.version "555" 275 - ''; 276 - }; 271 + gsp.enable = 272 + lib.mkEnableOption '' 273 + the GPU System Processor (GSP) on the video card 274 + '' 275 + // { 276 + default = useOpenModules || lib.versionAtLeast nvidia_x11.version "555"; 277 + defaultText = lib.literalExpression '' 278 + config.hardware.nvidia.open == true || lib.versionAtLeast config.hardware.nvidia.package.version "555" 279 + ''; 280 + }; 277 281 278 282 videoAcceleration = 279 283 (lib.mkEnableOption '' ··· 323 327 softdep nvidia post: nvidia-uvm 324 328 ''; 325 329 }; 326 - systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" ]; 330 + systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ 331 + "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" 332 + ]; 327 333 services.udev.extraRules = '' 328 334 # Create /dev/nvidia-uvm when the nvidia-uvm module is loaded. 329 335 KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c 195 255'" ··· 622 628 # If requested enable modesetting via kernel parameters. 623 629 kernelParams = 624 630 lib.optional (offloadCfg.enable || cfg.modesetting.enable) "nvidia-drm.modeset=1" 625 - ++ lib.optional ((offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545") "nvidia-drm.fbdev=1" 631 + ++ lib.optional ( 632 + (offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545" 633 + ) "nvidia-drm.fbdev=1" 626 634 ++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1" 627 635 ++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1" 628 636 ++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off"; ··· 683 691 TOPOLOGY_FILE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch"; 684 692 DATABASE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch"; 685 693 }; 686 - nv-fab-conf = settingsFormat.generate "fabricmanager.conf" (fabricManagerConfDefaults // cfg.datacenter.settings); 694 + nv-fab-conf = settingsFormat.generate "fabricmanager.conf" ( 695 + fabricManagerConfDefaults // cfg.datacenter.settings 696 + ); 687 697 in 688 698 "${lib.getExe nvidia_x11.fabricmanager} -c ${nv-fab-conf}"; 689 699 LimitCORE = "infinity";
+112 -91
pkgs/os-specific/linux/nvidia-x11/default.nix
··· 1 - { lib, callPackage, fetchFromGitHub, fetchgit, fetchpatch, stdenv, pkgsi686Linux }: 1 + { 2 + lib, 3 + callPackage, 4 + fetchFromGitHub, 5 + fetchgit, 6 + fetchpatch, 7 + stdenv, 8 + pkgsi686Linux, 9 + }: 2 10 3 11 let 4 - generic = args: let 5 - imported = import ./generic.nix args; 6 - in callPackage imported { 7 - lib32 = (pkgsi686Linux.callPackage imported { 8 - libsOnly = true; 9 - kernel = null; 10 - }).out; 11 - }; 12 + generic = 13 + args: 14 + let 15 + imported = import ./generic.nix args; 16 + in 17 + callPackage imported { 18 + lib32 = 19 + (pkgsi686Linux.callPackage imported { 20 + libsOnly = true; 21 + kernel = null; 22 + }).out; 23 + }; 12 24 13 - kernel = callPackage # a hacky way of extracting parameters from callPackage 14 - ({ kernel, libsOnly ? false }: if libsOnly then { } else kernel) { }; 25 + kernel = 26 + # a hacky way of extracting parameters from callPackage 27 + callPackage ( 28 + { 29 + kernel, 30 + libsOnly ? false, 31 + }: 32 + if libsOnly then { } else kernel 33 + ) { }; 15 34 16 - selectHighestVersion = a: b: if lib.versionOlder a.version b.version 17 - then b 18 - else a; 35 + selectHighestVersion = a: b: if lib.versionOlder a.version b.version then b else a; 19 36 20 37 # https://forums.developer.nvidia.com/t/linux-6-7-3-545-29-06-550-40-07-error-modpost-gpl-incompatible-module-nvidia-ko-uses-gpl-only-symbol-rcu-read-lock/280908/19 21 38 rcu_patch = fetchpatch { ··· 25 42 26 43 # Fixes drm device not working with linux 6.12 27 44 # https://github.com/NVIDIA/open-gpu-kernel-modules/issues/712 28 - drm_fop_flags_linux_612_patch = fetchpatch { 45 + drm_fop_flags_linux_612_patch = fetchpatch { 29 46 url = "https://github.com/Binary-Eater/open-gpu-kernel-modules/commit/8ac26d3c66ea88b0f80504bdd1e907658b41609d.patch"; 30 47 hash = "sha256-+SfIu3uYNQCf/KXhv4PWvruTVKQSh4bgU1moePhe57U="; 31 48 }; ··· 136 153 }; 137 154 138 155 # Last one supporting x86 139 - legacy_390 = let 140 - # Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms 141 - aurPatches = fetchgit { 142 - url = "https://aur.archlinux.org/nvidia-390xx-utils.git"; 143 - rev = "ebb48c240ce329e89ad3b59e78c8c708f46f27b3"; 144 - hash = "sha256-AGx3/EQ81awBMs6rrXTGWJmyq+UjBCPp6/9z1BQBB9E="; 156 + legacy_390 = 157 + let 158 + # Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms 159 + aurPatches = fetchgit { 160 + url = "https://aur.archlinux.org/nvidia-390xx-utils.git"; 161 + rev = "ebb48c240ce329e89ad3b59e78c8c708f46f27b3"; 162 + hash = "sha256-AGx3/EQ81awBMs6rrXTGWJmyq+UjBCPp6/9z1BQBB9E="; 163 + }; 164 + patchset = [ 165 + "kernel-4.16+-memory-encryption.patch" 166 + "kernel-6.2.patch" 167 + "kernel-6.3.patch" 168 + "kernel-6.4.patch" 169 + "kernel-6.5.patch" 170 + "kernel-6.6.patch" 171 + "kernel-6.8.patch" 172 + "gcc-14.patch" 173 + "kernel-6.10.patch" 174 + ]; 175 + in 176 + generic { 177 + version = "390.157"; 178 + sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k="; 179 + sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo="; 180 + settingsSha256 = "sha256-uJZO4ak/w/yeTQ9QdXJSiaURDLkevlI81de0q4PpFpw="; 181 + persistencedSha256 = "sha256-NuqUQbVt80gYTXgIcu0crAORfsj9BCRooyH3Gp1y1ns="; 182 + 183 + patches = map (patch: "${aurPatches}/${patch}") patchset; 184 + broken = kernel.kernelAtLeast "6.11 "; 185 + 186 + # fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439 187 + # see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651 188 + # and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699 189 + postInstall = '' 190 + mv $out/lib/tls/* $out/lib 191 + rmdir $out/lib/tls 192 + ''; 145 193 }; 146 - patchset = [ 147 - "kernel-4.16+-memory-encryption.patch" 148 - "kernel-6.2.patch" 149 - "kernel-6.3.patch" 150 - "kernel-6.4.patch" 151 - "kernel-6.5.patch" 152 - "kernel-6.6.patch" 153 - "kernel-6.8.patch" 154 - "gcc-14.patch" 155 - "kernel-6.10.patch" 156 - ]; 157 - in generic { 158 - version = "390.157"; 159 - sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k="; 160 - sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo="; 161 - settingsSha256 = "sha256-uJZO4ak/w/yeTQ9QdXJSiaURDLkevlI81de0q4PpFpw="; 162 - persistencedSha256 = "sha256-NuqUQbVt80gYTXgIcu0crAORfsj9BCRooyH3Gp1y1ns="; 163 194 164 - patches = map (patch: "${aurPatches}/${patch}") patchset; 165 - broken = kernel.kernelAtLeast "6.11 "; 195 + legacy_340 = 196 + let 197 + # Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms 198 + aurPatches = fetchFromGitHub { 199 + owner = "archlinux-jerry"; 200 + repo = "nvidia-340xx"; 201 + rev = "7616dfed253aa93ca7d2e05caf6f7f332c439c90"; 202 + hash = "sha256-1qlYc17aEbLD4W8XXn1qKryBk2ltT6cVIv5zAs0jXZo="; 203 + }; 204 + patchset = [ 205 + "0001-kernel-5.7.patch" 206 + "0002-kernel-5.8.patch" 207 + "0003-kernel-5.9.patch" 208 + "0004-kernel-5.10.patch" 209 + "0005-kernel-5.11.patch" 210 + "0006-kernel-5.14.patch" 211 + "0007-kernel-5.15.patch" 212 + "0008-kernel-5.16.patch" 213 + "0009-kernel-5.17.patch" 214 + "0010-kernel-5.18.patch" 215 + "0011-kernel-6.0.patch" 216 + "0012-kernel-6.2.patch" 217 + "0013-kernel-6.3.patch" 218 + "0014-kernel-6.5.patch" 219 + "0015-kernel-6.6.patch" 220 + ]; 221 + in 222 + generic { 223 + version = "340.108"; 224 + sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0"; 225 + sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6"; 226 + settingsSha256 = "0zm29jcf0mp1nykcravnzb5isypm8l8mg2gpsvwxipb7nk1ivy34"; 227 + persistencedSha256 = "1ax4xn3nmxg1y6immq933cqzw6cj04x93saiasdc0kjlv0pvvnkn"; 228 + useGLVND = false; 166 229 167 - # fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439 168 - # see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651 169 - # and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699 170 - postInstall = '' 171 - mv $out/lib/tls/* $out/lib 172 - rmdir $out/lib/tls 173 - ''; 174 - }; 230 + broken = kernel.kernelAtLeast "6.7"; 231 + patches = map (patch: "${aurPatches}/${patch}") patchset; 175 232 176 - legacy_340 = let 177 - # Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms 178 - aurPatches = fetchFromGitHub { 179 - owner = "archlinux-jerry"; 180 - repo = "nvidia-340xx"; 181 - rev = "7616dfed253aa93ca7d2e05caf6f7f332c439c90"; 182 - hash = "sha256-1qlYc17aEbLD4W8XXn1qKryBk2ltT6cVIv5zAs0jXZo="; 233 + # fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439 234 + # see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651 235 + # and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699 236 + postInstall = '' 237 + mv $out/lib/tls/* $out/lib 238 + rmdir $out/lib/tls 239 + ''; 183 240 }; 184 - patchset = [ 185 - "0001-kernel-5.7.patch" 186 - "0002-kernel-5.8.patch" 187 - "0003-kernel-5.9.patch" 188 - "0004-kernel-5.10.patch" 189 - "0005-kernel-5.11.patch" 190 - "0006-kernel-5.14.patch" 191 - "0007-kernel-5.15.patch" 192 - "0008-kernel-5.16.patch" 193 - "0009-kernel-5.17.patch" 194 - "0010-kernel-5.18.patch" 195 - "0011-kernel-6.0.patch" 196 - "0012-kernel-6.2.patch" 197 - "0013-kernel-6.3.patch" 198 - "0014-kernel-6.5.patch" 199 - "0015-kernel-6.6.patch" 200 - ]; 201 - in generic { 202 - version = "340.108"; 203 - sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0"; 204 - sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6"; 205 - settingsSha256 = "0zm29jcf0mp1nykcravnzb5isypm8l8mg2gpsvwxipb7nk1ivy34"; 206 - persistencedSha256 = "1ax4xn3nmxg1y6immq933cqzw6cj04x93saiasdc0kjlv0pvvnkn"; 207 - useGLVND = false; 208 - 209 - broken = kernel.kernelAtLeast "6.7"; 210 - patches = map (patch: "${aurPatches}/${patch}") patchset; 211 - 212 - # fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439 213 - # see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651 214 - # and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699 215 - postInstall = '' 216 - mv $out/lib/tls/* $out/lib 217 - rmdir $out/lib/tls 218 - ''; 219 - }; 220 241 }
+188 -131
pkgs/os-specific/linux/nvidia-x11/generic.nix
··· 1 - { version 2 - , url ? null 3 - , sha256_32bit ? null 4 - , sha256_64bit 5 - , sha256_aarch64 ? null 6 - , openSha256 ? null 7 - , settingsSha256 ? null 8 - , settingsVersion ? version 9 - , persistencedSha256 ? null 10 - , persistencedVersion ? version 11 - , fabricmanagerSha256 ? null 12 - , fabricmanagerVersion ? version 13 - , useGLVND ? true 14 - , useProfiles ? true 15 - , preferGtk2 ? false 16 - , settings32Bit ? false 17 - , useSettings ? true 18 - , usePersistenced ? true 19 - , useFabricmanager ? false 20 - , ibtSupport ? false 1 + { 2 + version, 3 + url ? null, 4 + sha256_32bit ? null, 5 + sha256_64bit, 6 + sha256_aarch64 ? null, 7 + openSha256 ? null, 8 + settingsSha256 ? null, 9 + settingsVersion ? version, 10 + persistencedSha256 ? null, 11 + persistencedVersion ? version, 12 + fabricmanagerSha256 ? null, 13 + fabricmanagerVersion ? version, 14 + useGLVND ? true, 15 + useProfiles ? true, 16 + preferGtk2 ? false, 17 + settings32Bit ? false, 18 + useSettings ? true, 19 + usePersistenced ? true, 20 + useFabricmanager ? false, 21 + ibtSupport ? false, 21 22 22 - , prePatch ? null 23 - , postPatch ? null 24 - , patchFlags ? null 25 - , patches ? [ ] 26 - , patchesOpen ? [ ] 27 - , preInstall ? null 28 - , postInstall ? null 29 - , broken ? false 30 - , brokenOpen ? broken 23 + prePatch ? null, 24 + postPatch ? null, 25 + patchFlags ? null, 26 + patches ? [ ], 27 + patchesOpen ? [ ], 28 + preInstall ? null, 29 + postInstall ? null, 30 + broken ? false, 31 + brokenOpen ? broken, 31 32 }@args: 32 33 33 - { lib 34 - , stdenv 35 - , runCommandLocal 36 - , patchutils 37 - , callPackage 38 - , pkgs 39 - , pkgsi686Linux 40 - , fetchurl 41 - , fetchzip 42 - , kernel ? null 43 - , perl 44 - , nukeReferences 45 - , which 46 - , libarchive 47 - , jq 48 - , # Whether to build the libraries only (i.e. not the kernel module or 34 + { 35 + lib, 36 + stdenv, 37 + runCommandLocal, 38 + patchutils, 39 + callPackage, 40 + pkgs, 41 + pkgsi686Linux, 42 + fetchurl, 43 + fetchzip, 44 + kernel ? null, 45 + perl, 46 + nukeReferences, 47 + which, 48 + libarchive, 49 + jq, 50 + # Whether to build the libraries only (i.e. not the kernel module or 49 51 # nvidia-settings). Used to support 32-bit binaries on 64-bit 50 52 # Linux. 51 - libsOnly ? false 52 - , # don't include the bundled 32-bit libraries on 64-bit platforms, 53 + libsOnly ? false, 54 + # don't include the bundled 32-bit libraries on 64-bit platforms, 53 55 # even if it’s in downloaded binary 54 - disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux" 56 + disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux", 55 57 # 32 bit libs only version of this package 56 - , lib32 ? null 58 + lib32 ? null, 57 59 # Whether to extract the GSP firmware, datacenter drivers needs to extract the 58 60 # firmware 59 - , firmware ? openSha256 != null || useFabricmanager 61 + firmware ? openSha256 != null || useFabricmanager, 60 62 # Whether the user accepts the NVIDIA Software License 61 - , config 62 - , acceptLicense ? config.nvidia.acceptLicense or false 63 + config, 64 + acceptLicense ? config.nvidia.acceptLicense or false, 63 65 }: 64 66 65 67 assert !libsOnly -> kernel != null; ··· 97 99 pkgSuffix = lib.optionalString (lib.versionOlder version "304") "-pkg0"; 98 100 i686bundled = lib.versionAtLeast version "391" && !disable32Bit; 99 101 100 - libPathFor = pkgs: lib.makeLibraryPath (with pkgs; [ 101 - libdrm 102 - xorg.libXext 103 - xorg.libX11 104 - xorg.libXv 105 - xorg.libXrandr 106 - xorg.libxcb 107 - zlib 108 - stdenv.cc.cc 109 - wayland 110 - mesa 111 - libGL 112 - openssl 113 - dbus # for nvidia-powerd 114 - ]); 102 + libPathFor = 103 + pkgs: 104 + lib.makeLibraryPath ( 105 + with pkgs; 106 + [ 107 + libdrm 108 + xorg.libXext 109 + xorg.libX11 110 + xorg.libXv 111 + xorg.libXrandr 112 + xorg.libxcb 113 + zlib 114 + stdenv.cc.cc 115 + wayland 116 + mesa 117 + libGL 118 + openssl 119 + dbus # for nvidia-powerd 120 + ] 121 + ); 115 122 116 123 # maybe silly since we've ignored this previously and just unfree.. 117 124 throwLicense = throw '' ··· 139 146 builder = ./builder.sh; 140 147 141 148 src = 142 - if !acceptLicense && (openSha256 == null) then throwLicense else 143 - if stdenv.hostPlatform.system == "x86_64-linux" then 144 - fetchurl 145 - { 146 - urls = if args ? url then [ args.url ] else [ 147 - "https://us.download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run" 148 - "https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run" 149 - ]; 150 - sha256 = sha256_64bit; 151 - } 149 + if !acceptLicense && (openSha256 == null) then 150 + throwLicense 151 + else if stdenv.hostPlatform.system == "x86_64-linux" then 152 + fetchurl { 153 + urls = 154 + if args ? url then 155 + [ args.url ] 156 + else 157 + [ 158 + "https://us.download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run" 159 + "https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run" 160 + ]; 161 + sha256 = sha256_64bit; 162 + } 152 163 else if stdenv.hostPlatform.system == "i686-linux" then 153 - fetchurl 154 - { 155 - urls = if args ? url then [ args.url ] else [ 156 - "https://us.download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run" 157 - "https://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run" 158 - ]; 159 - sha256 = sha256_32bit; 160 - } 164 + fetchurl { 165 + urls = 166 + if args ? url then 167 + [ args.url ] 168 + else 169 + [ 170 + "https://us.download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run" 171 + "https://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run" 172 + ]; 173 + sha256 = sha256_32bit; 174 + } 161 175 else if stdenv.hostPlatform.system == "aarch64-linux" && sha256_aarch64 != null then 162 - fetchurl 163 - { 164 - urls = if args ? url then [ args.url ] else [ 165 - "https://us.download.nvidia.com/XFree86/aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run" 166 - "https://download.nvidia.com/XFree86/Linux-aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run" 167 - ]; 168 - sha256 = sha256_aarch64; 169 - } 170 - else throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}"; 176 + fetchurl { 177 + urls = 178 + if args ? url then 179 + [ args.url ] 180 + else 181 + [ 182 + "https://us.download.nvidia.com/XFree86/aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run" 183 + "https://download.nvidia.com/XFree86/Linux-aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run" 184 + ]; 185 + sha256 = sha256_aarch64; 186 + } 187 + else 188 + throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}"; 171 189 172 190 patches = 173 191 if libsOnly then ··· 186 204 inherit (stdenv.hostPlatform) system; 187 205 inherit i686bundled; 188 206 189 - outputs = [ "out" ] 207 + outputs = 208 + [ "out" ] 190 209 ++ lib.optional i686bundled "lib32" 191 210 ++ lib.optional (!libsOnly) "bin" 192 211 ++ lib.optional (!libsOnly && firmware) "firmware"; ··· 195 214 kernel = if libsOnly then null else kernel.dev; 196 215 kernelVersion = if libsOnly then null else kernel.modDirVersion; 197 216 198 - makeFlags = lib.optionals (!libsOnly) (kernel.makeFlags ++ [ 199 - "IGNORE_PREEMPT_RT_PRESENCE=1" 200 - "NV_BUILD_SUPPORTS_HMM=1" 201 - "SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source" 202 - "SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" 203 - ]); 217 + makeFlags = lib.optionals (!libsOnly) ( 218 + kernel.makeFlags 219 + ++ [ 220 + "IGNORE_PREEMPT_RT_PRESENCE=1" 221 + "NV_BUILD_SUPPORTS_HMM=1" 222 + "SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source" 223 + "SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" 224 + ] 225 + ); 204 226 205 - hardeningDisable = [ "pic" "format" ]; 227 + hardeningDisable = [ 228 + "pic" 229 + "format" 230 + ]; 206 231 207 232 dontStrip = true; 208 233 dontPatchELF = true; ··· 210 235 libPath = libPathFor pkgs; 211 236 libPath32 = lib.optionalString i686bundled (libPathFor pkgsi686Linux); 212 237 213 - nativeBuildInputs = [ perl nukeReferences which libarchive jq ] 214 - ++ lib.optionals (!libsOnly) kernel.moduleBuildDependencies; 238 + nativeBuildInputs = [ 239 + perl 240 + nukeReferences 241 + which 242 + libarchive 243 + jq 244 + ] ++ lib.optionals (!libsOnly) kernel.moduleBuildDependencies; 215 245 216 246 disallowedReferences = lib.optionals (!libsOnly) [ kernel.dev ]; 217 247 218 248 passthru = 219 249 let 220 - fetchFromGithubOrNvidia = { owner, repo, rev, ... }@args: 250 + fetchFromGithubOrNvidia = 251 + { 252 + owner, 253 + repo, 254 + rev, 255 + ... 256 + }@args: 221 257 let 222 - args' = builtins.removeAttrs args [ "owner" "repo" "rev" ]; 258 + args' = builtins.removeAttrs args [ 259 + "owner" 260 + "repo" 261 + "rev" 262 + ]; 223 263 baseUrl = "https://github.com/${owner}/${repo}"; 224 264 in 225 - fetchzip (args' // { 226 - urls = [ 227 - "${baseUrl}/archive/${rev}.tar.gz" 228 - "https://download.nvidia.com/XFree86/${repo}/${repo}-${rev}.tar.bz2" 229 - ]; 230 - # github and nvidia use different compression algorithms, 231 - # use an invalid file extension to force detection. 232 - extension = "tar.??"; 233 - }); 265 + fetchzip ( 266 + args' 267 + // { 268 + urls = [ 269 + "${baseUrl}/archive/${rev}.tar.gz" 270 + "https://download.nvidia.com/XFree86/${repo}/${repo}-${rev}.tar.bz2" 271 + ]; 272 + # github and nvidia use different compression algorithms, 273 + # use an invalid file extension to force detection. 274 + extension = "tar.??"; 275 + } 276 + ); 234 277 in 235 278 { 236 - open = lib.mapNullable 237 - (hash: callPackage ./open.nix { 279 + open = lib.mapNullable ( 280 + hash: 281 + callPackage ./open.nix { 238 282 inherit hash; 239 283 nvidia_x11 = self; 240 284 patches = ··· 244 288 }) patches) 245 289 ++ patchesOpen; 246 290 broken = brokenOpen; 247 - }) 248 - openSha256; 291 + } 292 + ) openSha256; 249 293 settings = 250 294 if useSettings then 251 - (if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) 295 + (if settings32Bit then pkgsi686Linux.callPackage else callPackage) 296 + (import ./settings.nix self settingsSha256) 252 297 { 253 298 withGtk2 = preferGtk2; 254 299 withGtk3 = !preferGtk2; 255 300 fetchFromGitHub = fetchFromGithubOrNvidia; 256 - } else { }; 301 + } 302 + else 303 + { }; 257 304 persistenced = 258 305 if usePersistenced then 259 - lib.mapNullable 260 - (hash: callPackage (import ./persistenced.nix self hash) { 306 + lib.mapNullable ( 307 + hash: 308 + callPackage (import ./persistenced.nix self hash) { 261 309 fetchFromGitHub = fetchFromGithubOrNvidia; 262 - }) 263 - persistencedSha256 264 - else { }; 310 + } 311 + ) persistencedSha256 312 + else 313 + { }; 265 314 fabricmanager = 266 315 if useFabricmanager then 267 316 lib.mapNullable (hash: callPackage (import ./fabricmanager.nix self hash) { }) fabricmanagerSha256 268 - else { }; 317 + else 318 + { }; 269 319 inherit persistencedVersion settingsVersion; 270 320 compressFirmware = false; 271 321 ibtSupport = ibtSupport || (lib.versionAtLeast version "530"); 272 - } // lib.optionalAttrs (!i686bundled) { 322 + } 323 + // lib.optionalAttrs (!i686bundled) { 273 324 inherit lib32; 274 325 }; 275 326 276 327 meta = with lib; { 277 328 homepage = "https://www.nvidia.com/object/unix.html"; 278 - description = "${if useFabricmanager then "Data Center" else "X.org"} driver and kernel module for NVIDIA cards"; 329 + description = "${ 330 + if useFabricmanager then "Data Center" else "X.org" 331 + } driver and kernel module for NVIDIA cards"; 279 332 license = licenses.unfreeRedistributable; 280 - platforms = [ "x86_64-linux" ] 333 + platforms = 334 + [ "x86_64-linux" ] 281 335 ++ lib.optionals (sha256_32bit != null) [ "i686-linux" ] 282 336 ++ lib.optionals (sha256_aarch64 != null) [ "aarch64-linux" ]; 283 - maintainers = with maintainers; [ kiskae edwtjo ]; 337 + maintainers = with maintainers; [ 338 + kiskae 339 + edwtjo 340 + ]; 284 341 priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so" 285 342 inherit broken; 286 343 };
+52 -41
pkgs/os-specific/linux/nvidia-x11/open.nix
··· 1 - { stdenv 2 - , lib 3 - , fetchFromGitHub 4 - , kernel 5 - , nvidia_x11 6 - , hash 7 - , patches ? [ ] 8 - , broken ? false 1 + { 2 + stdenv, 3 + lib, 4 + fetchFromGitHub, 5 + kernel, 6 + nvidia_x11, 7 + hash, 8 + patches ? [ ], 9 + broken ? false, 9 10 }: 10 11 11 - stdenv.mkDerivation ({ 12 - pname = "nvidia-open"; 13 - version = "${kernel.version}-${nvidia_x11.version}"; 12 + stdenv.mkDerivation ( 13 + { 14 + pname = "nvidia-open"; 15 + version = "${kernel.version}-${nvidia_x11.version}"; 14 16 15 - src = fetchFromGitHub { 16 - owner = "NVIDIA"; 17 - repo = "open-gpu-kernel-modules"; 18 - rev = nvidia_x11.version; 19 - inherit hash; 20 - }; 17 + src = fetchFromGitHub { 18 + owner = "NVIDIA"; 19 + repo = "open-gpu-kernel-modules"; 20 + rev = nvidia_x11.version; 21 + inherit hash; 22 + }; 21 23 22 - inherit patches; 24 + inherit patches; 23 25 24 - nativeBuildInputs = kernel.moduleBuildDependencies; 26 + nativeBuildInputs = kernel.moduleBuildDependencies; 25 27 26 - makeFlags = kernel.makeFlags ++ [ 27 - "SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source" 28 - "SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" 29 - "MODLIB=$(out)/lib/modules/${kernel.modDirVersion}" 30 - { 31 - aarch64-linux = "TARGET_ARCH=aarch64"; 32 - x86_64-linux = "TARGET_ARCH=x86_64"; 33 - }.${stdenv.hostPlatform.system} 34 - ]; 28 + makeFlags = kernel.makeFlags ++ [ 29 + "SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source" 30 + "SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" 31 + "MODLIB=$(out)/lib/modules/${kernel.modDirVersion}" 32 + { 33 + aarch64-linux = "TARGET_ARCH=aarch64"; 34 + x86_64-linux = "TARGET_ARCH=x86_64"; 35 + } 36 + .${stdenv.hostPlatform.system} 37 + ]; 35 38 36 - installTargets = [ "modules_install" ]; 37 - enableParallelBuilding = true; 39 + installTargets = [ "modules_install" ]; 40 + enableParallelBuilding = true; 38 41 39 - meta = with lib; { 40 - description = "NVIDIA Linux Open GPU Kernel Module"; 41 - homepage = "https://github.com/NVIDIA/open-gpu-kernel-modules"; 42 - license = with licenses; [ gpl2Plus mit ]; 43 - platforms = [ "x86_64-linux" "aarch64-linux" ]; 44 - maintainers = with maintainers; [ nickcao ]; 45 - inherit broken; 46 - }; 47 - } // lib.optionalAttrs stdenv.hostPlatform.isAarch64 { 48 - env.NIX_CFLAGS_COMPILE = "-fno-stack-protector"; 49 - }) 42 + meta = with lib; { 43 + description = "NVIDIA Linux Open GPU Kernel Module"; 44 + homepage = "https://github.com/NVIDIA/open-gpu-kernel-modules"; 45 + license = with licenses; [ 46 + gpl2Plus 47 + mit 48 + ]; 49 + platforms = [ 50 + "x86_64-linux" 51 + "aarch64-linux" 52 + ]; 53 + maintainers = with maintainers; [ nickcao ]; 54 + inherit broken; 55 + }; 56 + } 57 + // lib.optionalAttrs stdenv.hostPlatform.isAarch64 { 58 + env.NIX_CFLAGS_COMPILE = "-fno-stack-protector"; 59 + } 60 + )
+92 -57
pkgs/os-specific/linux/nvidia-x11/settings.nix
··· 1 1 nvidia_x11: sha256: 2 2 3 - { stdenv 4 - , lib 5 - , fetchFromGitHub 6 - , fetchpatch 7 - , pkg-config 8 - , m4 9 - , jansson 10 - , gtk2 11 - , dbus 12 - , vulkan-headers 13 - , gtk3 14 - , libXv 15 - , libXrandr 16 - , libXext 17 - , libXxf86vm 18 - , libvdpau 19 - , librsvg 20 - , libglvnd 21 - , wrapGAppsHook3 22 - , addDriverRunpath 23 - , withGtk2 ? false 24 - , withGtk3 ? true 3 + { 4 + stdenv, 5 + lib, 6 + fetchFromGitHub, 7 + fetchpatch, 8 + pkg-config, 9 + m4, 10 + jansson, 11 + gtk2, 12 + dbus, 13 + vulkan-headers, 14 + gtk3, 15 + libXv, 16 + libXrandr, 17 + libXext, 18 + libXxf86vm, 19 + libvdpau, 20 + librsvg, 21 + libglvnd, 22 + wrapGAppsHook3, 23 + addDriverRunpath, 24 + withGtk2 ? false, 25 + withGtk3 ? true, 25 26 }: 26 27 27 28 let ··· 35 36 meta = with lib; { 36 37 homepage = "https://www.nvidia.com/object/unix.html"; 37 38 platforms = nvidia_x11.meta.platforms; 38 - maintainers = with maintainers; [ abbradar aidalgol ]; 39 + maintainers = with maintainers; [ 40 + abbradar 41 + aidalgol 42 + ]; 39 43 }; 40 44 41 45 libXNVCtrl = stdenv.mkDerivation { ··· 43 47 version = nvidia_x11.settingsVersion; 44 48 inherit src; 45 49 46 - buildInputs = [ libXrandr libXext ]; 50 + buildInputs = [ 51 + libXrandr 52 + libXext 53 + ]; 47 54 48 55 preBuild = '' 49 56 cd src/libXNVCtrl ··· 57 64 58 65 patches = [ 59 66 # Patch the Makefile to also produce a shared library. 60 - (if lib.versionOlder nvidia_x11.settingsVersion "400" then ./libxnvctrl-build-shared-3xx.patch 61 - else ./libxnvctrl-build-shared.patch) 67 + ( 68 + if lib.versionOlder nvidia_x11.settingsVersion "400" then 69 + ./libxnvctrl-build-shared-3xx.patch 70 + else 71 + ./libxnvctrl-build-shared.patch 72 + ) 62 73 ]; 63 74 64 75 installPhase = '' ··· 79 90 }; 80 91 81 92 runtimeDependencies = [ 82 - libglvnd libXrandr libXv 93 + libglvnd 94 + libXrandr 95 + libXv 83 96 ]; 84 97 85 98 runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies; ··· 92 105 93 106 inherit src; 94 107 95 - patches = lib.optional (lib.versionOlder nvidia_x11.settingsVersion "440") 96 - (fetchpatch { 108 + patches = 109 + lib.optional (lib.versionOlder nvidia_x11.settingsVersion "440") (fetchpatch { 97 110 # fixes "multiple definition of `VDPAUDeviceFunctions'" linking errors 98 111 url = "https://github.com/NVIDIA/nvidia-settings/commit/a7c1f5fce6303a643fadff7d85d59934bd0cf6b6.patch"; 99 112 hash = "sha256-ZwF3dRTYt/hO8ELg9weoz1U/XcU93qiJL2d1aq1Jlak="; 100 113 }) 101 - ++ lib.optional 102 - ((lib.versionAtLeast nvidia_x11.settingsVersion "515.43.04") 103 - && (lib.versionOlder nvidia_x11.settingsVersion "545.29")) 104 - (fetchpatch { 105 - # fix wayland support for compositors that use wl_output version 4 106 - url = "https://github.com/NVIDIA/nvidia-settings/pull/99/commits/2e0575197e2b3247deafd2a48f45afc038939a06.patch"; 107 - hash = "sha256-wKuO5CUTUuwYvsP46Pz+6fI0yxLNpZv8qlbL0TFkEFE="; 108 - }); 114 + ++ lib.optional 115 + ( 116 + (lib.versionAtLeast nvidia_x11.settingsVersion "515.43.04") 117 + && (lib.versionOlder nvidia_x11.settingsVersion "545.29") 118 + ) 119 + (fetchpatch { 120 + # fix wayland support for compositors that use wl_output version 4 121 + url = "https://github.com/NVIDIA/nvidia-settings/pull/99/commits/2e0575197e2b3247deafd2a48f45afc038939a06.patch"; 122 + hash = "sha256-wKuO5CUTUuwYvsP46Pz+6fI0yxLNpZv8qlbL0TFkEFE="; 123 + }); 109 124 110 125 postPatch = lib.optionalString nvidia_x11.useProfiles '' 111 126 sed -i 's,/usr/share/nvidia/,${nvidia_x11.bin}/share/nvidia/,g' src/gtk+-2.x/ctkappprofile.c ··· 122 137 fi 123 138 ''; 124 139 125 - nativeBuildInputs = [ pkg-config m4 addDriverRunpath ] 126 - ++ lib.optionals withGtk3 [ wrapGAppsHook3 ]; 140 + nativeBuildInputs = [ 141 + pkg-config 142 + m4 143 + addDriverRunpath 144 + ] ++ lib.optionals withGtk3 [ wrapGAppsHook3 ]; 127 145 128 - buildInputs = [ jansson libXv libXrandr libXext libXxf86vm libvdpau nvidia_x11 dbus vulkan-headers ] 146 + buildInputs = 147 + [ 148 + jansson 149 + libXv 150 + libXrandr 151 + libXext 152 + libXxf86vm 153 + libvdpau 154 + nvidia_x11 155 + dbus 156 + vulkan-headers 157 + ] 129 158 ++ lib.optionals (withGtk2 || lib.versionOlder nvidia_x11.settingsVersion "525.53") [ gtk2 ] 130 - ++ lib.optionals withGtk3 [ gtk3 librsvg ]; 159 + ++ lib.optionals withGtk3 [ 160 + gtk3 161 + librsvg 162 + ]; 131 163 132 164 installFlags = [ "PREFIX=$(out)" ]; 133 165 134 - postInstall = lib.optionalString (!withGtk2) '' 135 - rm -f $out/lib/libnvidia-gtk2.so.* 136 - '' + lib.optionalString (!withGtk3) '' 137 - rm -f $out/lib/libnvidia-gtk3.so.* 138 - '' + '' 139 - # Install the desktop file and icon. 140 - # The template has substitution variables intended to be replaced resulting 141 - # in absolute paths. Because absolute paths break after the desktop file is 142 - # copied by a desktop environment, make Exec and Icon be just a name. 143 - sed -i doc/nvidia-settings.desktop \ 144 - -e "s|^Exec=.*$|Exec=nvidia-settings|" \ 145 - -e "s|^Icon=.*$|Icon=nvidia-settings|" \ 146 - -e "s|__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__|Settings|g" 147 - install doc/nvidia-settings.desktop -D -t $out/share/applications/ 148 - install doc/nvidia-settings.png -D -t $out/share/icons/hicolor/128x128/apps/ 149 - ''; 166 + postInstall = 167 + lib.optionalString (!withGtk2) '' 168 + rm -f $out/lib/libnvidia-gtk2.so.* 169 + '' 170 + + lib.optionalString (!withGtk3) '' 171 + rm -f $out/lib/libnvidia-gtk3.so.* 172 + '' 173 + + '' 174 + # Install the desktop file and icon. 175 + # The template has substitution variables intended to be replaced resulting 176 + # in absolute paths. Because absolute paths break after the desktop file is 177 + # copied by a desktop environment, make Exec and Icon be just a name. 178 + sed -i doc/nvidia-settings.desktop \ 179 + -e "s|^Exec=.*$|Exec=nvidia-settings|" \ 180 + -e "s|^Icon=.*$|Icon=nvidia-settings|" \ 181 + -e "s|__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__|Settings|g" 182 + install doc/nvidia-settings.desktop -D -t $out/share/applications/ 183 + install doc/nvidia-settings.png -D -t $out/share/icons/hicolor/128x128/apps/ 184 + ''; 150 185 151 186 binaryName = if withGtk3 then ".nvidia-settings-wrapped" else "nvidia-settings"; 152 187 postFixup = ''