2020-04-24 23:36:52 +00:00
|
|
|
|
{ version
|
2020-09-25 04:45:31 +00:00
|
|
|
|
, url ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, sha256_32bit ? null
|
|
|
|
|
, sha256_64bit
|
|
|
|
|
, settingsSha256
|
2020-09-25 04:45:31 +00:00
|
|
|
|
, settingsVersion ? version
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, persistencedSha256
|
2020-09-25 04:45:31 +00:00
|
|
|
|
, persistencedVersion ? version
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, useGLVND ? true
|
|
|
|
|
, useProfiles ? true
|
|
|
|
|
, preferGtk2 ? false
|
|
|
|
|
, settings32Bit ? false
|
|
|
|
|
|
|
|
|
|
, prePatch ? ""
|
|
|
|
|
, patches ? []
|
|
|
|
|
, broken ? false
|
2020-09-25 04:45:31 +00:00
|
|
|
|
}@args:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
|
{ lib, stdenv, callPackage, pkgs, pkgsi686Linux, fetchurl
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, kernel ? null, perl, nukeReferences
|
|
|
|
|
, # 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-09-25 04:45:31 +00:00
|
|
|
|
, # don't include the bundled 32-bit libraries on 64-bit platforms,
|
|
|
|
|
# even if it’s in downloaded binary
|
|
|
|
|
disable32Bit ? false
|
2021-02-05 17:12:51 +00:00
|
|
|
|
# 32 bit libs only version of this package
|
|
|
|
|
, lib32 ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
|
}:
|
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
assert !libsOnly -> kernel != null;
|
|
|
|
|
assert versionOlder version "391" -> sha256_32bit != null;
|
|
|
|
|
assert ! versionOlder version "391" -> stdenv.hostPlatform.system == "x86_64-linux";
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
nameSuffix = optionalString (!libsOnly) "-${kernel.version}";
|
|
|
|
|
pkgSuffix = optionalString (versionOlder version "304") "-pkg0";
|
2020-09-25 04:45:31 +00:00
|
|
|
|
i686bundled = versionAtLeast version "391" && !disable32Bit;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-12-06 16:07:01 +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
|
|
|
|
|
]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
self = stdenv.mkDerivation {
|
|
|
|
|
name = "nvidia-x11-${version}${nameSuffix}";
|
|
|
|
|
|
|
|
|
|
builder = ./builder.sh;
|
|
|
|
|
|
|
|
|
|
src =
|
|
|
|
|
if stdenv.hostPlatform.system == "x86_64-linux" then
|
|
|
|
|
fetchurl {
|
2021-04-19 03:05:28 +00:00
|
|
|
|
url = args.url or "https://us.download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
sha256 = sha256_64bit;
|
|
|
|
|
}
|
|
|
|
|
else if stdenv.hostPlatform.system == "i686-linux" then
|
|
|
|
|
fetchurl {
|
2020-09-25 04:45:31 +00:00
|
|
|
|
url = args.url or "https://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
sha256 = sha256_32bit;
|
|
|
|
|
}
|
|
|
|
|
else throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}";
|
|
|
|
|
|
|
|
|
|
patches = if libsOnly then null else patches;
|
|
|
|
|
inherit prePatch;
|
|
|
|
|
inherit version useGLVND useProfiles;
|
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
|
inherit i686bundled;
|
|
|
|
|
|
|
|
|
|
outputs = [ "out" ]
|
|
|
|
|
++ optional i686bundled "lib32"
|
|
|
|
|
++ optional (!libsOnly) "bin";
|
|
|
|
|
outputDev = if libsOnly then null else "bin";
|
|
|
|
|
|
|
|
|
|
kernel = if libsOnly then null else kernel.dev;
|
|
|
|
|
kernelVersion = if libsOnly then null else kernel.modDirVersion;
|
|
|
|
|
|
2021-09-18 10:52:07 +00: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"
|
|
|
|
|
]);
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
hardeningDisable = [ "pic" "format" ];
|
|
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
|
|
|
|
|
libPath = libPathFor pkgs;
|
|
|
|
|
libPath32 = optionalString i686bundled (libPathFor pkgsi686Linux);
|
|
|
|
|
|
|
|
|
|
nativeBuildInputs = [ perl nukeReferences ]
|
|
|
|
|
++ optionals (!libsOnly) kernel.moduleBuildDependencies;
|
|
|
|
|
|
|
|
|
|
disallowedReferences = optional (!libsOnly) [ kernel.dev ];
|
|
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
|
settings = (if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) {
|
|
|
|
|
withGtk2 = preferGtk2;
|
|
|
|
|
withGtk3 = !preferGtk2;
|
|
|
|
|
};
|
|
|
|
|
persistenced = mapNullable (hash: callPackage (import ./persistenced.nix self hash) { }) persistencedSha256;
|
2020-09-25 04:45:31 +00:00
|
|
|
|
inherit persistencedVersion settingsVersion;
|
2021-02-05 17:12:51 +00:00
|
|
|
|
} // optionalAttrs (!i686bundled) {
|
|
|
|
|
inherit lib32;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
homepage = "https://www.nvidia.com/object/unix.html";
|
|
|
|
|
description = "X.org driver and kernel module for NVIDIA graphics cards";
|
|
|
|
|
license = licenses.unfreeRedistributable;
|
2020-07-18 16:06:22 +00:00
|
|
|
|
platforms = [ "x86_64-linux" ] ++ optionals (!i686bundled) [ "i686-linux" ];
|
2021-09-22 15:38:15 +00:00
|
|
|
|
maintainers = with maintainers; [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so"
|
|
|
|
|
inherit broken;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
in self
|