2017-01-29 21:29:39 +00:00
|
|
|
{ version
|
|
|
|
, sha256_32bit
|
|
|
|
, sha256_64bit
|
|
|
|
, settingsSha256
|
|
|
|
, persistencedSha256
|
|
|
|
, useGLVND ? true
|
2017-02-11 14:11:18 +00:00
|
|
|
, useProfiles ? true
|
2017-01-29 21:29:39 +00:00
|
|
|
, preferGtk2 ? false
|
|
|
|
}:
|
|
|
|
|
2017-05-12 09:00:49 +01:00
|
|
|
{ stdenv, callPackage, callPackage_i686, fetchurl, fetchpatch
|
2017-01-29 21:29:39 +00:00
|
|
|
, kernel ? null, xorg, zlib, 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
|
|
|
|
}:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
assert (!libsOnly) -> kernel != null;
|
|
|
|
|
|
|
|
let
|
|
|
|
nameSuffix = optionalString (!libsOnly) "-${kernel.version}";
|
|
|
|
pkgSuffix = optionalString (versionOlder version "304") "-pkg0";
|
|
|
|
|
|
|
|
self = stdenv.mkDerivation {
|
|
|
|
name = "nvidia-x11-${version}${nameSuffix}";
|
|
|
|
|
|
|
|
builder = ./builder.sh;
|
|
|
|
|
|
|
|
src =
|
|
|
|
if stdenv.system == "i686-linux" then
|
|
|
|
fetchurl {
|
2017-04-29 22:19:04 +01:00
|
|
|
url = "https://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run";
|
2017-01-29 21:29:39 +00:00
|
|
|
sha256 = sha256_32bit;
|
|
|
|
}
|
|
|
|
else if stdenv.system == "x86_64-linux" then
|
|
|
|
fetchurl {
|
2017-04-29 22:19:04 +01:00
|
|
|
url = "https://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;
|
|
|
|
}
|
|
|
|
else throw "nvidia-x11 does not support platform ${stdenv.system}";
|
|
|
|
|
2017-05-31 09:45:44 +01:00
|
|
|
prePatch = let
|
|
|
|
debPatches = fetchurl {
|
|
|
|
url = "mirror://debian/pool/non-free/n/nvidia-graphics-drivers-legacy-304xx/"
|
|
|
|
+ "nvidia-graphics-drivers-legacy-304xx_304.135-2.debian.tar.xz";
|
|
|
|
sha256 = "0mhji0ssn7075q5a650idigs48kzf11pzj2ca2n07rwxg3vj6pdr";
|
|
|
|
};
|
|
|
|
prefix = "debian/module/debian/patches";
|
|
|
|
applyPatches = pnames: if pnames == [] then null else
|
|
|
|
''
|
|
|
|
tar xf '${debPatches}'
|
|
|
|
sed 's|^\([+-]\{3\} [ab]\)/|\1/kernel/|' -i ${prefix}/*.patch
|
|
|
|
patches="$patches ${concatMapStringsSep " " (pname: "${prefix}/${pname}.patch") pnames}"
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
# TODO: perhaps other branches also need patching?
|
|
|
|
if (versionOlder version "340") then applyPatches
|
|
|
|
[ "fix-typos" "drm-driver-legacy" "deprecated-cpu-events" "disable-mtrr" ]
|
|
|
|
else null;
|
|
|
|
|
2017-03-06 20:59:51 +00:00
|
|
|
# patch to get the nvidia and nvidiaBeta driver to compile on kernel 4.10
|
2017-04-16 21:08:20 +01:00
|
|
|
patches = if libsOnly
|
2017-03-06 20:59:51 +00:00
|
|
|
then null
|
2017-04-16 21:08:20 +01:00
|
|
|
else if versionOlder version "340"
|
|
|
|
then null
|
|
|
|
else if versionOlder version "375"
|
|
|
|
then [
|
2017-05-12 09:00:49 +01:00
|
|
|
(fetchpatch {
|
|
|
|
name = "kernel-4.10.patch";
|
|
|
|
url = https://git.archlinux.org/svntogit/packages.git/plain/nvidia-340xx/trunk/4.10.0_kernel.patch?id=53fb1df89;
|
|
|
|
sha256 = "171hb57m968qdjcr3h8ppfzhrchf573f39rdja86a1qq1gmrv7pa";
|
2017-04-16 21:08:20 +01:00
|
|
|
})
|
|
|
|
# from https://git.archlinux.org/svntogit/packages.git/plain/trunk/fs52243.patch?h=packages/nvidia-340xx
|
|
|
|
# with datestamps removed
|
|
|
|
./fs52243.patch
|
|
|
|
]
|
2017-05-11 10:06:26 +01:00
|
|
|
else null;
|
2017-03-06 20:59:51 +00:00
|
|
|
|
2017-02-11 14:11:18 +00:00
|
|
|
inherit version useGLVND useProfiles;
|
2017-01-29 21:29:39 +00:00
|
|
|
inherit (stdenv) system;
|
|
|
|
|
|
|
|
outputs = [ "out" ] ++ optional (!libsOnly) "bin";
|
|
|
|
outputDev = if libsOnly then null else "bin";
|
|
|
|
|
|
|
|
kernel = if libsOnly then null else kernel.dev;
|
|
|
|
|
|
|
|
hardeningDisable = [ "pic" "format" ];
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
|
|
|
libPath = makeLibraryPath [ xorg.libXext xorg.libX11 xorg.libXv xorg.libXrandr zlib stdenv.cc.cc ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ perl nukeReferences ];
|
|
|
|
|
|
|
|
disallowedReferences = optional (!libsOnly) [ kernel.dev ];
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
settings = callPackage (import ./settings.nix self settingsSha256) {
|
|
|
|
withGtk2 = preferGtk2;
|
|
|
|
withGtk3 = !preferGtk2;
|
|
|
|
};
|
2017-04-17 21:48:10 +01:00
|
|
|
persistenced = mapNullable (hash: callPackage (import ./persistenced.nix self hash) { }) persistencedSha256;
|
2017-01-29 21:29:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = http://www.nvidia.com/object/unix.html;
|
|
|
|
description = "X.org driver and kernel module for NVIDIA graphics cards";
|
|
|
|
license = licenses.unfreeRedistributable;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = [ maintainers.vcunat ];
|
|
|
|
priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in self
|