1- { stdenv ,
1+ {
2+ # General arguments supplied by callPackage
3+ stdenv ,
24 backendStdenv ,
35 lib ,
46 lndir ,
57 zlib ,
6- useCudatoolkitRunfile ? false ,
7- cudaVersion ,
8- cudaMajorVersion ,
9- cudatoolkit , # For cuda < 11
108 libcublas ? null , # cuda <11 doesn't ship redist packages
119 autoPatchelfHook ,
1210 autoAddOpenGLRunpathHook ,
1311 fetchurl ,
14- } : {
15- version ,
16- url ,
17- hash ,
18- minCudaVersion ,
19- maxCudaVersion ,
12+ cudatoolkit , # For cuda < 11
13+ cudaVersion ,
14+ # Arguments supplied by the caller
15+ useCudatoolkitRunfile ? false ,
16+ # See ../modules/cudnn/releases/package.nix for type of package
17+ package ,
18+ # Platforms supported by the package
19+ # platforms :: List String
20+ platforms ,
2021} :
21- assert useCudatoolkitRunfile || ( libcublas != null ) ; let
22- inherit ( lib ) lists strings trivial versions ;
22+ assert libcublas == null -> useCudatoolkitRunfile ; let
23+ inherit ( lib ) lists strings trivial versions maintainers licenses meta sourceTypes ;
2324
2425 # majorMinorPatch :: String -> String
2526 majorMinorPatch = ( trivial . flip trivial . pipe ) [
@@ -30,16 +31,16 @@ assert useCudatoolkitRunfile || (libcublas != null); let
3031
3132 # versionTriple :: String
3233 # Version with three components: major.minor.patch
33- versionTriple = majorMinorPatch version ;
34+ versionTriple = majorMinorPatch package . version ;
3435in
3536 backendStdenv . mkDerivation {
36- pname = "cudatoolkit- ${ cudaMajorVersion } - cudnn" ;
37- version = versionTriple ;
37+ pname = "cudnn" ;
38+ inherit ( package ) version ;
3839 strictDeps = true ;
3940 outputs = [ "out" "lib" "static" "dev" ] ;
4041
4142 src = fetchurl {
42- inherit url hash ;
43+ inherit ( package ) url hash ;
4344 } ;
4445
4546 # We do need some other phases, like configurePhase, so the multiple-output setup hook works.
5354 ] ;
5455
5556 # Used by autoPatchelfHook
56- buildInputs = [
57- # Note this libstdc++ isn't from the (possibly older) nvcc-compatible
58- # stdenv, but from the (newer) stdenv that the rest of nixpkgs uses
59- stdenv . cc . cc . lib
60-
61- zlib
62- ] ++ lists . optionals useCudatoolkitRunfile [
63- cudatoolkit
64- ] ++ lists . optionals ( ! useCudatoolkitRunfile ) [
65- libcublas . lib
66- ] ;
57+ buildInputs =
58+ [
59+ # Note this libstdc++ isn't from the (possibly older) nvcc-compatible
60+ # stdenv, but from the (newer) stdenv that the rest of nixpkgs uses
61+ stdenv . cc . cc . lib
62+
63+ zlib
64+ ]
65+ ++ lists . optionals useCudatoolkitRunfile [
66+ cudatoolkit
67+ ]
68+ ++ lists . optionals ( ! useCudatoolkitRunfile ) [
69+ libcublas . lib
70+ ] ;
6771
6872 # We used to patch Runpath here, but now we use autoPatchelfHook
6973 #
7478 # output.
7579 # Note that moveToOutput operates on all outputs:
7680 # https://github.com/NixOS/nixpkgs/blob/2920b6fc16a9ed5d51429e94238b28306ceda79e/pkgs/build-support/setup-hooks/multiple-outputs.sh#L105-L107
77- installPhase =
78- ''
79- runHook preInstall
81+ installPhase = ''
82+ runHook preInstall
8083
81- mkdir -p "$out"
82- mv * "$out"
83- moveToOutput "lib64" "$lib"
84- moveToOutput "lib" "$lib"
85- moveToOutput "**/*.a" "$static"
84+ mkdir -p "$out"
85+ mv * "$out"
86+ moveToOutput "lib64" "$lib"
87+ moveToOutput "lib" "$lib"
88+ moveToOutput "**/*.a" "$static"
8689
87- runHook postInstall
88- '' ;
90+ runHook postInstall
91+ '' ;
8992
9093 # Without --add-needed autoPatchelf forgets $ORIGIN on cuda>=8.0.5.
9194 postFixup = strings . optionalString ( strings . versionAtLeast versionTriple "8.0.5" ) ''
109112 # found: <customPhaseName>".
110113 postPatchelf = ''
111114 mkdir -p "$out"
112- ${ lib . meta . getExe lndir } "$lib" "$out"
113- ${ lib . meta . getExe lndir } "$static" "$out"
114- ${ lib . meta . getExe lndir } "$dev" "$out"
115+ ${ meta . getExe lndir } "$lib" "$out"
116+ ${ meta . getExe lndir } "$static" "$out"
117+ ${ meta . getExe lndir } "$dev" "$out"
115118 '' ;
116119
117120 passthru = {
132135 # unqualified (that is, without an explicit output).
133136 outputSpecified = true ;
134137
135- meta = with lib ; {
138+ meta = {
136139 # Check that the cudatoolkit version satisfies our min/max constraints (both
137140 # inclusive). We mark the package as broken if it fails to satisfies the
138141 # official version constraints (as recorded in default.nix). In some cases
139142 # you _may_ be able to smudge version constraints, just know that you're
140143 # embarking into unknown and unsupported territory when doing so.
141144 broken =
142- strings . versionOlder cudaVersion minCudaVersion
143- || strings . versionOlder maxCudaVersion cudaVersion ;
145+ strings . versionOlder cudaVersion package . minCudaVersion
146+ || strings . versionOlder package . maxCudaVersion cudaVersion ;
144147 description = "NVIDIA CUDA Deep Neural Network library (cuDNN)" ;
145148 homepage = "https://developer.nvidia.com/cudnn" ;
146149 sourceProvenance = with sourceTypes ; [ binaryNativeCode ] ;
147150 # TODO: consider marking unfreRedistributable when not using runfile
148151 license = licenses . unfree ;
149- platforms = [ "x86_64-linux" ] ;
150- maintainers = with maintainers ; [ mdaiter samuela ] ;
152+ inherit platforms ;
153+ maintainers = with maintainers ; [ mdaiter samuela connorbaker ] ;
151154 # Force the use of the default, fat output by default (even though `dev` exists, which
152155 # causes Nix to prefer that output over the others if outputSpecified isn't set).
153156 outputsToInstall = [ "out" ] ;
0 commit comments