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