Skip to content

config: add replaceStdenv, cudaCapabilities, cudaForwardCompat options#479234

Merged
philiptaron merged 4 commits intoNixOS:masterfrom
byteforge38:config-add-undeclared-options
Jan 16, 2026
Merged

config: add replaceStdenv, cudaCapabilities, cudaForwardCompat options#479234
philiptaron merged 4 commits intoNixOS:masterfrom
byteforge38:config-add-undeclared-options

Conversation

@byteforge38
Copy link
Contributor

Fixes #479220

Users with config.warnUndeclaredOptions = true were getting warnings for replaceStdenv, cudaCapabilities, and cudaForwardCompat because these options were used but not declared in pkgs/top-level/config.nix.

This PR adds proper option declarations for:

  • cudaCapabilities: A list of CUDA capabilities to build for (default: [])
  • cudaForwardCompat: Whether to enable PTX support for future hardware (default: true)
  • replaceStdenv: A function to replace the standard environment globally (default: null)

Also updates pkgs/stdenv/default.nix to check (config.replaceStdenv or null) != null instead of config ? replaceStdenv, since the option now always exists but may be null.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.


Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=4217675

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.first-time contribution This PR is the author's first one; please be gentle! 6.topic: stdenv Standard environment labels Jan 12, 2026
@philiptaron
Copy link
Contributor

philiptaron commented Jan 12, 2026

See ##330753 for the last time a similar thing was attempted by @eclairevoyant.

Declaring previously-undeclared options broke the config.foo or default fallback pattern used throughout nixpkgs because declared options always exist (even if unset), preventing the or operator from using its default value.

Can you read through that PR and make sure you're not falling into the same trap?

@byteforge38
Copy link
Contributor Author

Thanks for the heads up! I took a look at #330753 — the issue there was that the declared defaults didn't match the existing fallback values, which broke the or pattern.

In this PR, I made sure to align the defaults with what the code already expects: [] for cudaCapabilities, true for cudaForwardCompat, and null for replaceStdenv. I also updated the check in pkgs/stdenv/default.nix from config ? replaceStdenv to (config.replaceStdenv or null) != null to handle the declared-but-null case.

Verified with nix-build -A tests.config and everything passes.

@byteforge38
Copy link
Contributor Author

Hmmm... turns out it's not dead code - CI failed cuz some contexts like tarball builds don't go through the module system, so the attribute doesn't exist there. Let me revert it

@eclairevoyant
Copy link
Contributor

Mind adding a comment there in the code, then?

@byteforge38
Copy link
Contributor Author

Mind adding a comment there in the code, then?

Done

@philiptaron philiptaron requested a review from a team January 16, 2026 17:29
@philiptaron
Copy link
Contributor

cc @NixOS/cuda-maintainers who I would think are 👍🏻 on this

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jan 16, 2026
@ConnorBaker
Copy link
Contributor

In principle I'm okay with this; I do want to warn you that adding types for some options can have unintended consequences via strictness induced by module system checking the types. I ran into some infinite recursion errors when I had tried adding options for allowlistedLicenses and blocklistedLicenses previously.

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 3+ This PR was reviewed and approved by three or more persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Jan 16, 2026
@philiptaron philiptaron added this pull request to the merge queue Jan 16, 2026
Merged via the queue into NixOS:master with commit 8a5aae2 Jan 16, 2026
31 of 33 checks passed
@github-project-automation github-project-automation bot moved this to Done in Stdenv Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: stdenv Standard environment 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 3+ This PR was reviewed and approved by three or more persons. 12.first-time contribution This PR is the author's first one; please be gentle!

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Config Request: add options for replaceStdenv, cudaCapabilities, cudaForwardCompat

4 participants