NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.89k stars 13.95k forks source link

overridding arguments to cudnn is difficult #116691

Open cdepillabout opened 3 years ago

cdepillabout commented 3 years ago

Describe the bug

The way the CUDNN packages are defined makes it difficult to override any of the values. This is due to the slightly weird interaction between how CUDNN uses callPackages and callPackage.

For instance, even though the CUDNN derivations take fetchurl as an argument, you can't override fetchurl in the CUDNN derivation:

$ nix-build -E 'with import ./. {}; cudnn_cudatoolkit_11_2.override { fetchurl = fetchurl; }'
error: anonymous function at pkgs/development/libraries/science/math/cudnn/default.nix:1:1 called with unexpected argument 'fetchurl', at lib/customisation.nix:170:63

The above is run on commit e3c1c3b.

I explain why this happens, give a workaround, and suggest a fix in this comment: https://github.com/NixOS/nixpkgs/pull/115768#issuecomment-796397428

Notify maintainers

@mdaiter

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
  - cudnn
  - cudnnPackages
  - cudnn_cudatoolkit_11
  - cudnn_cudatoolkit_11_2
# a list of nixos modules affected by the problem
module:
stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

SomeoneSerge commented 7 months ago

@NixOS/cuda-maintainers note that the situation got even more complicated now that manifest.nix and multiplex.nix have been introduced: our .override isn't really public anymore, only overrideAttrs andoverrideScope are. Note also that the original point about wrapping multiple layers of callPackage still stands e.g. for cudaPackages.backendStdenv.

Another instance where the issue with .overrides shows is pyproject.nix: it produces values that can be rendered into a buildPythonPackage (...) value, but not into a callPackage-able values ("recipes", cf. https://fosdem.org/2024/schedule/event/fosdem-2024-3107-units-of-composition-recipes-overlays-and-packages/)