2017-01-29 21:29:39 +00:00
|
|
|
|
{ version
|
2020-09-24 15:53:05 +01:00
|
|
|
|
, url ? null
|
2018-08-11 16:32:00 +01:00
|
|
|
|
, sha256_32bit ? null
|
2017-01-29 21:29:39 +00:00
|
|
|
|
, sha256_64bit
|
|
|
|
|
, settingsSha256
|
2020-09-24 15:53:05 +01:00
|
|
|
|
, settingsVersion ? version
|
2017-01-29 21:29:39 +00:00
|
|
|
|
, persistencedSha256
|
2020-09-24 15:53:05 +01:00
|
|
|
|
, persistencedVersion ? version
|
2017-01-29 21:29:39 +00:00
|
|
|
|
, useGLVND ? true
|
2017-02-11 14:11:18 +00:00
|
|
|
|
, useProfiles ? true
|
2017-01-29 21:29:39 +00:00
|
|
|
|
, preferGtk2 ? false
|
2018-03-27 14:40:33 +01:00
|
|
|
|
, settings32Bit ? false
|
2017-05-31 14:52:03 +01:00
|
|
|
|
|
|
|
|
|
, prePatch ? ""
|
|
|
|
|
, patches ? []
|
2018-12-02 10:45:13 +00:00
|
|
|
|
, broken ? false
|
2020-09-24 15:53:05 +01:00
|
|
|
|
}@args:
|
2017-01-29 21:29:39 +00:00
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
|
{ lib, stdenv, callPackage, pkgs, pkgsi686Linux, fetchurl
|
2022-01-26 09:23:20 +00:00
|
|
|
|
, kernel ? null, perl, nukeReferences, which
|
2017-01-29 21:29:39 +00:00
|
|
|
|
, # Whether to build the libraries only (i.e. not the kernel module or
|
|
|
|
|
# nvidia-settings). Used to support 32-bit binaries on 64-bit
|
|
|
|
|
# Linux.
|
|
|
|
|
libsOnly ? false
|
2020-08-20 16:29:28 +01:00
|
|
|
|
, # don't include the bundled 32-bit libraries on 64-bit platforms,
|
|
|
|
|
# even if it’s in downloaded binary
|
|
|
|
|
disable32Bit ? false
|
2018-11-03 18:50:12 +00:00
|
|
|
|
# 32 bit libs only version of this package
|
|
|
|
|
, lib32 ? null
|
2017-01-29 21:29:39 +00:00
|
|
|
|
}:
|
|
|
|
|
|
2021-01-15 14:45:37 +00:00
|
|
|
|
with lib;
|
2017-01-29 21:29:39 +00:00
|
|
|
|
|
2018-08-11 16:32:00 +01:00
|
|
|
|
assert !libsOnly -> kernel != null;
|
|
|
|
|
assert versionOlder version "391" -> sha256_32bit != null;
|
2022-04-25 21:35:24 +01:00
|
|
|
|
assert versionAtLeast version "391" -> stdenv.hostPlatform.system == "x86_64-linux";
|
2017-01-29 21:29:39 +00:00
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
nameSuffix = optionalString (!libsOnly) "-${kernel.version}";
|
|
|
|
|
pkgSuffix = optionalString (versionOlder version "304") "-pkg0";
|
2020-08-20 16:29:28 +01:00
|
|
|
|
i686bundled = versionAtLeast version "391" && !disable32Bit;
|
2018-08-11 16:32:00 +01:00
|
|
|
|
|
2021-11-14 22:43:35 +00:00
|
|
|
|
libPathFor = pkgs: lib.makeLibraryPath (with pkgs; [
|
|
|
|
|
libdrm xorg.libXext xorg.libX11
|
|
|
|
|
xorg.libXv xorg.libXrandr xorg.libxcb zlib stdenv.cc.cc
|
|
|
|
|
wayland mesa libGL
|
|
|
|
|
]);
|
2017-01-29 21:29:39 +00:00
|
|
|
|
|
|
|
|
|
self = stdenv.mkDerivation {
|
|
|
|
|
name = "nvidia-x11-${version}${nameSuffix}";
|
|
|
|
|
|
|
|
|
|
builder = ./builder.sh;
|
|
|
|
|
|
|
|
|
|
src =
|
2018-08-11 16:32:00 +01:00
|
|
|
|
if stdenv.hostPlatform.system == "x86_64-linux" then
|
2017-01-29 21:29:39 +00:00
|
|
|
|
fetchurl {
|
2021-04-16 10:48:20 +01:00
|
|
|
|
url = args.url or "https://us.download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run";
|
2017-01-29 21:29:39 +00:00
|
|
|
|
sha256 = sha256_64bit;
|
|
|
|
|
}
|
2018-08-11 16:32:00 +01:00
|
|
|
|
else if stdenv.hostPlatform.system == "i686-linux" then
|
|
|
|
|
fetchurl {
|
2020-09-24 15:53:05 +01:00
|
|
|
|
url = args.url or "https://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run";
|
2018-08-11 16:32:00 +01:00
|
|
|
|
sha256 = sha256_32bit;
|
|
|
|
|
}
|
2018-08-20 20:11:29 +01:00
|
|
|
|
else throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}";
|
2017-01-29 21:29:39 +00:00
|
|
|
|
|
2017-05-31 14:52:03 +01:00
|
|
|
|
patches = if libsOnly then null else patches;
|
|
|
|
|
inherit prePatch;
|
2017-02-11 14:11:18 +00:00
|
|
|
|
inherit version useGLVND useProfiles;
|
2018-08-20 20:11:29 +01:00
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
2018-08-11 16:32:00 +01:00
|
|
|
|
inherit i686bundled;
|
2017-01-29 21:29:39 +00:00
|
|
|
|
|
2018-08-11 16:32:00 +01:00
|
|
|
|
outputs = [ "out" ]
|
|
|
|
|
++ optional i686bundled "lib32"
|
|
|
|
|
++ optional (!libsOnly) "bin";
|
2017-01-29 21:29:39 +00:00
|
|
|
|
outputDev = if libsOnly then null else "bin";
|
|
|
|
|
|
|
|
|
|
kernel = if libsOnly then null else kernel.dev;
|
2018-06-24 09:49:08 +01:00
|
|
|
|
kernelVersion = if libsOnly then null else kernel.modDirVersion;
|
2017-01-29 21:29:39 +00:00
|
|
|
|
|
2021-08-31 00:41:23 +01:00
|
|
|
|
makeFlags = optionals (!libsOnly) (kernel.makeFlags ++ [
|
|
|
|
|
"IGNORE_PREEMPT_RT_PRESENCE=1"
|
|
|
|
|
"NV_BUILD_SUPPORTS_HMM=1"
|
|
|
|
|
"SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
|
|
|
|
|
"SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
|
|
|
|
|
]);
|
2021-08-31 00:27:26 +01:00
|
|
|
|
|
2017-01-29 21:29:39 +00:00
|
|
|
|
hardeningDisable = [ "pic" "format" ];
|
|
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
|
2019-06-08 14:23:05 +01:00
|
|
|
|
libPath = libPathFor pkgs;
|
|
|
|
|
libPath32 = optionalString i686bundled (libPathFor pkgsi686Linux);
|
2017-01-29 21:29:39 +00:00
|
|
|
|
|
2022-01-26 09:23:20 +00:00
|
|
|
|
buildInputs = [ which ];
|
2017-12-30 16:44:45 +00:00
|
|
|
|
nativeBuildInputs = [ perl nukeReferences ]
|
|
|
|
|
++ optionals (!libsOnly) kernel.moduleBuildDependencies;
|
2017-12-28 12:16:26 +00:00
|
|
|
|
|
2017-01-29 21:29:39 +00:00
|
|
|
|
disallowedReferences = optional (!libsOnly) [ kernel.dev ];
|
|
|
|
|
|
|
|
|
|
passthru = {
|
2018-07-05 19:04:52 +01:00
|
|
|
|
settings = (if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) {
|
2017-01-29 21:29:39 +00:00
|
|
|
|
withGtk2 = preferGtk2;
|
|
|
|
|
withGtk3 = !preferGtk2;
|
|
|
|
|
};
|
2017-04-17 21:48:10 +01:00
|
|
|
|
persistenced = mapNullable (hash: callPackage (import ./persistenced.nix self hash) { }) persistencedSha256;
|
2020-09-24 15:53:05 +01:00
|
|
|
|
inherit persistencedVersion settingsVersion;
|
2018-11-03 18:50:12 +00:00
|
|
|
|
} // optionalAttrs (!i686bundled) {
|
|
|
|
|
inherit lib32;
|
2017-01-29 21:29:39 +00:00
|
|
|
|
};
|
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
|
meta = with lib; {
|
2020-04-01 02:11:51 +01:00
|
|
|
|
homepage = "https://www.nvidia.com/object/unix.html";
|
2017-01-29 21:29:39 +00:00
|
|
|
|
description = "X.org driver and kernel module for NVIDIA graphics cards";
|
|
|
|
|
license = licenses.unfreeRedistributable;
|
2020-06-25 00:54:11 +01:00
|
|
|
|
platforms = [ "x86_64-linux" ] ++ optionals (!i686bundled) [ "i686-linux" ];
|
2022-02-05 22:01:11 +00:00
|
|
|
|
maintainers = with maintainers; [ jonringer ];
|
2017-01-29 21:29:39 +00:00
|
|
|
|
priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so"
|
2018-12-02 10:45:13 +00:00
|
|
|
|
inherit broken;
|
2017-01-29 21:29:39 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
in self
|