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
|
2023-04-29 16:46:19 +00:00
|
|
|
|
, sha256_aarch64 ? null
|
2022-06-26 10:26:21 +00:00
|
|
|
|
, openSha256 ? null
|
2023-10-09 19:29:22 +00:00
|
|
|
|
, settingsSha256 ? null
|
2020-09-25 04:45:31 +00:00
|
|
|
|
, settingsVersion ? version
|
2023-10-09 19:29:22 +00:00
|
|
|
|
, persistencedSha256 ? null
|
2020-09-25 04:45:31 +00:00
|
|
|
|
, persistencedVersion ? version
|
2023-10-09 19:29:22 +00:00
|
|
|
|
, fabricmanagerSha256 ? null
|
|
|
|
|
, fabricmanagerVersion ? version
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, useGLVND ? true
|
|
|
|
|
, useProfiles ? true
|
|
|
|
|
, preferGtk2 ? false
|
|
|
|
|
, settings32Bit ? false
|
2023-10-09 19:29:22 +00:00
|
|
|
|
, useSettings ? true
|
|
|
|
|
, usePersistenced ? true
|
|
|
|
|
, useFabricmanager ? false
|
2023-04-12 12:48:02 +00:00
|
|
|
|
, ibtSupport ? false
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
, prePatch ? ""
|
2023-03-15 16:39:30 +00:00
|
|
|
|
, postPatch ? null
|
2023-05-24 13:37:59 +00:00
|
|
|
|
, patchFlags ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, patches ? []
|
|
|
|
|
, broken ? false
|
2022-09-09 14:08:57 +00:00
|
|
|
|
, brokenOpen ? broken
|
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
|
2023-03-30 22:05:00 +00:00
|
|
|
|
, kernel ? null, perl, nukeReferences, which, libarchive
|
2020-04-24 23:36:52 +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-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
|
2023-04-29 16:46:19 +00:00
|
|
|
|
disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux"
|
2021-02-05 17:12:51 +00:00
|
|
|
|
# 32 bit libs only version of this package
|
|
|
|
|
, lib32 ? null
|
2023-10-09 19:29:22 +00:00
|
|
|
|
# Whether to extract the GSP firmware, datacenter drivers needs to extract the
|
|
|
|
|
# firmware
|
|
|
|
|
, firmware ? openSha256 != null || useFabricmanager
|
|
|
|
|
# Whether the user accepts the NVIDIA Software License
|
|
|
|
|
, config, acceptLicense ? config.nvidia.acceptLicense or false
|
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;
|
2023-10-09 19:29:22 +00:00
|
|
|
|
assert useSettings -> settingsSha256 != null;
|
|
|
|
|
assert usePersistenced -> persistencedSha256 != null;
|
|
|
|
|
assert useFabricmanager -> fabricmanagerSha256 != null;
|
|
|
|
|
assert useFabricmanager -> !(useSettings || usePersistenced);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
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
|
2023-07-15 17:15:38 +00:00
|
|
|
|
wayland mesa libGL openssl
|
2023-08-22 20:05:09 +00:00
|
|
|
|
dbus # for nvidia-powerd
|
2021-12-06 16:07:01 +00:00
|
|
|
|
]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
# maybe silly since we've ignored this previously and just unfree..
|
|
|
|
|
throwLicense = throw ''
|
|
|
|
|
Use of NVIDIA Software requires license acceptance of the license:
|
|
|
|
|
|
|
|
|
|
- License For Customer Use of NVIDIA Software [1]
|
|
|
|
|
|
|
|
|
|
You can express acceptance by setting acceptLicense to true your nixpkgs.config.
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
configuration.nix:
|
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
|
nixpkgs.config.nvidia.acceptLicense = true;
|
|
|
|
|
|
|
|
|
|
config.nix:
|
|
|
|
|
allowUnfree = true;
|
|
|
|
|
nvidia.acceptLicense = true;
|
|
|
|
|
|
|
|
|
|
[1]: https://www.nvidia.com/content/DriverDownloads/licence.php?lang=us
|
|
|
|
|
'';
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
self = stdenv.mkDerivation {
|
2023-10-09 19:29:22 +00:00
|
|
|
|
name = "nvidia-${if useFabricmanager then "dc" else "x11"}-${version}${nameSuffix}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
builder = ./builder.sh;
|
|
|
|
|
|
|
|
|
|
src =
|
2023-10-09 19:29:22 +00:00
|
|
|
|
if !acceptLicense && (openSha256 == null) then throwLicense else
|
2020-04-24 23:36:52 +00:00
|
|
|
|
if stdenv.hostPlatform.system == "x86_64-linux" then
|
|
|
|
|
fetchurl {
|
2023-04-29 16:46:19 +00:00
|
|
|
|
urls = if args ? url then [ args.url ] else [
|
|
|
|
|
"https://us.download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run"
|
|
|
|
|
"https://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 {
|
2023-04-29 16:46:19 +00:00
|
|
|
|
urls = if args ? url then [ args.url ] else [
|
|
|
|
|
"https://us.download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run"
|
|
|
|
|
"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;
|
|
|
|
|
}
|
2023-04-29 16:46:19 +00:00
|
|
|
|
else if stdenv.hostPlatform.system == "aarch64-linux" && sha256_aarch64 != null then
|
|
|
|
|
fetchurl {
|
|
|
|
|
urls = if args ? url then [ args.url ] else [
|
|
|
|
|
"https://us.download.nvidia.com/XFree86/aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run"
|
|
|
|
|
"https://download.nvidia.com/XFree86/Linux-aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run"
|
|
|
|
|
];
|
|
|
|
|
sha256 = sha256_aarch64;
|
|
|
|
|
}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
else throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}";
|
|
|
|
|
|
|
|
|
|
patches = if libsOnly then null else patches;
|
2023-05-24 13:37:59 +00:00
|
|
|
|
inherit prePatch postPatch patchFlags;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
inherit version useGLVND useProfiles;
|
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
|
inherit i686bundled;
|
|
|
|
|
|
|
|
|
|
outputs = [ "out" ]
|
|
|
|
|
++ optional i686bundled "lib32"
|
2022-06-26 10:26:21 +00:00
|
|
|
|
++ optional (!libsOnly) "bin"
|
|
|
|
|
++ optional (!libsOnly && firmware) "firmware";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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);
|
|
|
|
|
|
2023-03-30 22:05:00 +00:00
|
|
|
|
nativeBuildInputs = [ perl nukeReferences which libarchive ]
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ optionals (!libsOnly) kernel.moduleBuildDependencies;
|
|
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
|
disallowedReferences = optionals (!libsOnly) [ kernel.dev ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
passthru = {
|
2022-08-21 13:32:41 +00:00
|
|
|
|
open = mapNullable (hash: callPackage ./open.nix {
|
2022-09-09 14:08:57 +00:00
|
|
|
|
inherit hash;
|
2022-08-21 13:32:41 +00:00
|
|
|
|
nvidia_x11 = self;
|
2022-09-09 14:08:57 +00:00
|
|
|
|
broken = brokenOpen;
|
2022-08-21 13:32:41 +00:00
|
|
|
|
}) openSha256;
|
2023-10-09 19:29:22 +00:00
|
|
|
|
settings = if useSettings then
|
|
|
|
|
(if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) {
|
|
|
|
|
withGtk2 = preferGtk2;
|
|
|
|
|
withGtk3 = !preferGtk2;
|
|
|
|
|
} else {};
|
|
|
|
|
persistenced = if usePersistenced then
|
|
|
|
|
mapNullable (hash: callPackage (import ./persistenced.nix self hash) { }) persistencedSha256
|
|
|
|
|
else {};
|
|
|
|
|
fabricmanager = if useFabricmanager then
|
|
|
|
|
mapNullable (hash: callPackage (import ./fabricmanager.nix self hash) { }) fabricmanagerSha256
|
|
|
|
|
else {};
|
2020-09-25 04:45:31 +00:00
|
|
|
|
inherit persistencedVersion settingsVersion;
|
2022-10-21 18:38:19 +00:00
|
|
|
|
compressFirmware = false;
|
2023-04-12 12:48:02 +00:00
|
|
|
|
ibtSupport = ibtSupport || (lib.versionAtLeast version "530");
|
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";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
description = "${if useFabricmanager then "Data Center" else "X.org"} driver and kernel module for NVIDIA cards";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
license = licenses.unfreeRedistributable;
|
2023-04-29 16:46:19 +00:00
|
|
|
|
platforms = [ "x86_64-linux" ]
|
|
|
|
|
++ optionals (sha256_32bit != null) [ "i686-linux" ]
|
|
|
|
|
++ optionals (sha256_aarch64 != null) [ "aarch64-linux" ];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
maintainers = with maintainers; [ jonringer kiskae edwtjo ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so"
|
2023-03-04 12:14:45 +00:00
|
|
|
|
inherit broken;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
in self
|