From d6f8f7b7b1bbac1f5eba3110a12379857cba6950 Mon Sep 17 00:00:00 2001 From: byteforge38 Date: Sun, 11 Jan 2026 20:36:36 -0800 Subject: [PATCH 1/4] config: add replaceStdenv, cudaCapabilities, cudaForwardCompat options --- pkgs/stdenv/default.nix | 2 +- pkgs/top-level/config.nix | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 3bc88f59c4bb..53f63245c919 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -43,7 +43,7 @@ in # Select the appropriate stages for the platform `system'. if crossSystem != localSystem || crossOverlays != [ ] then stagesCross -else if config ? replaceStdenv then +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"; }; From abfadb9b476e914106642cf27a1c88a985dbc4e5 Mon Sep 17 00:00:00 2001 From: byteforge38 Date: Thu, 15 Jan 2026 19:00:55 -0800 Subject: [PATCH 2/4] stdenv: simplify replaceStdenv null check --- pkgs/stdenv/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 53f63245c919..98aefc2bf568 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -43,7 +43,7 @@ in # Select the appropriate stages for the platform `system'. if crossSystem != localSystem || crossOverlays != [ ] then stagesCross -else if (config.replaceStdenv or null) != null then +else if config.replaceStdenv != null then stagesCustom else if localSystem.isLinux then stagesLinux From 2c84f41a8e27d9a17ac15e22afef495af3ba55c9 Mon Sep 17 00:00:00 2001 From: byteforge38 Date: Thu, 15 Jan 2026 19:08:33 -0800 Subject: [PATCH 3/4] stdenv: keep replaceStdenv fallback for non-module contexts --- pkgs/stdenv/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 98aefc2bf568..53f63245c919 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -43,7 +43,7 @@ in # Select the appropriate stages for the platform `system'. if crossSystem != localSystem || crossOverlays != [ ] then stagesCross -else if config.replaceStdenv != null then +else if (config.replaceStdenv or null) != null then stagesCustom else if localSystem.isLinux then stagesLinux From d4e55d835ee3e7f62c4c670128e9eaa574c141cc Mon Sep 17 00:00:00 2001 From: byteforge38 Date: Fri, 16 Jan 2026 06:38:19 -0800 Subject: [PATCH 4/4] stdenv: add comment explaining replaceStdenv fallback --- pkgs/stdenv/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 53f63245c919..3cbe274a2f0e 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -43,6 +43,7 @@ in # Select the appropriate stages for the platform `system'. if crossSystem != localSystem || crossOverlays != [ ] then stagesCross +# 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