diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 3bc88f59c4bb..3cbe274a2f0e 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -43,7 +43,8 @@ in # Select the appropriate stages for the platform `system'. if crossSystem != localSystem || crossOverlays != [ ] then stagesCross -else if config ? replaceStdenv then +# The `or null` fallback is needed for contexts that don't use the module system (e.g. tarball builds). +else if (config.replaceStdenv or null) != null then stagesCustom else if localSystem.isLinux then stagesLinux diff --git a/pkgs/top-level/config.nix b/pkgs/top-level/config.nix index c8e8a3f58590..757274fd1dc7 100644 --- a/pkgs/top-level/config.nix +++ b/pkgs/top-level/config.nix @@ -266,6 +266,38 @@ let feature = "build packages with CUDA support by default"; }; + cudaCapabilities = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + A list of CUDA capabilities to build for. + + Packages may use this option to control device code generation to + take advantage of architecture-specific functionality, speed up + compile times by producing less device code, or slim package closures. + + For example, you can build for Ada Lovelace GPUs with + `cudaCapabilities = [ "8.9" ];`. + + If not provided, the default value is calculated per-package set, + derived from a list of GPUs supported by that CUDA version. + + See the [CUDA section](https://nixos.org/manual/nixpkgs/stable/#cuda) in + the Nixpkgs manual for more information. + ''; + }; + + cudaForwardCompat = mkOption { + type = types.bool; + default = true; + description = '' + Whether to enable PTX support for future hardware. + + When enabled, packages will include PTX code that can be JIT-compiled + for GPUs newer than those explicitly targeted by `cudaCapabilities`. + ''; + }; + replaceBootstrapFiles = mkMassRebuild { type = types.functionTo (types.attrsOf types.package); default = lib.id; @@ -294,6 +326,22 @@ let ''; }; + replaceStdenv = mkMassRebuild { + type = types.nullOr (types.functionTo types.package); + default = null; + defaultText = literalExpression "null"; + description = '' + A function to replace the standard environment (stdenv). + + The function receives an attribute set with `pkgs` and should return + a stdenv derivation. + + This can be used to globally replace the stdenv with a custom one, + for example to use ccache or distcc. + ''; + example = literalExpression "{ pkgs }: pkgs.ccacheStdenv"; + }; + rocmSupport = mkMassRebuild { feature = "build packages with ROCm support by default"; };