Repository navigation
Description
This assertion was introduced in #437723 to "prevent the common mistake of using CUDA tooling to build a CUDA application but forgetting to enable config.cudaSupport, resulting in an application which supports CUDA and dependencies which do not." (see #456510).
However, setting config.cudaSupport globally has wide-reaching consequences, and many unwanted side effects, such as having to rebuild large packages where CUDA functionality is not desired, or packages that are unrelated to any CUDA functionality. I've verified this for select packages, by evaluating their store paths with nixpkgs.config.cudaSupport set to true and false respectively. Here are some examples:
cudaSupport == false:
- librewolf-unwrapped:
/nix/store/i94j3y1sf8lnsvil8lwwzw6wdc7mskhk-librewolf-unwrapped-144.0-1 - cachix:
/nix/store/knc7ang3115l4xq0nl79pfl9xjrz2l7h-cachix-1.9.1-bin
cudaSupport == true:
- librewolf-unwrapped:
/nix/store/zb7xdyhkhcyaz0ry3ckbf4nf90kcpa2n-librewolf-unwrapped-144.0-1(very large build; does not utilize CUDA afaict) - cachix:
/nix/store/567p03nip3n40bigdrldfr8qw7mw65mx-cachix-1.9.1-bin(entirely unrelated to any sort of GPU work)
As it stands, globally enabling nixpkgs.config.cudaSupport is very much unrealistic, at least for desktop installations. The rationale cited behind requiring this variable to be set for certain CUDA package is understandable, however a more reasonable (imo) approach would be to override the affected dependencies within individual derivations, e.g.:
# some-package.nix
{
cudaSupport ? config.cudaSupport,
...
}:
stdenv.mkDerivation {
# ...
buildInputs = [
# ...
(someDependency.override {
inherit cudaSupport;
})
# can do to arbitrary depths
(someOtherDependency.override {
deepCudaDependency = deepCudaDependency.override {
inherit cudaSupport;
};
})
] ++ (lib.optionals cudaSupport [
# cuda dependencies
]);
}This would ensure that the unintended side effects from enabling cudaSupport only for select packages would be mitigated, thus no longer requiring config.cudaSupport to be enabled globally. FWIW, Blender already does exactly this, even for deeper dependencies.
I'm aware that the current limitations can be worked around by allowing the affected "broken" packages to be installed. However, marking them as broken to begin with sends a confusing message to users, and the assertion text that is returned when building with --trace-verbose (an argument I'm not sure many are familiar with) suggests to enable config.cudaSupport globally, which, as outlined, is a sub-optimal solution.
If users should still be notified when installing certain CUDA packages without enabling config.cudaSupport, I think an evaluation warning would be appropriate, but stopping evaluation altogether (as is current behavior) is not wise.
As a side note, there are also packages making use of CUDA libraries by default, such as nvtopPackages.full, which are currently entirely uninstallable for no good reason. I don't think that it's wise to gate certain packages' ability to be installed behind config variables, as this can be incredibly difficult to work around on non-NixOS and non-home-manager systems, especially for less experienced users.
It also makes it impossible to use commands like nix run github:NixOS/nixpkgs#nvtopPackages.full to quickly test a package (e.g. as part of a review, or to try something out before installing it).
cc @ConnorBaker
Activity