pkgs/top-level/stage.nix: add crossStdenv#410056
pkgs/top-level/stage.nix: add crossStdenv#410056RossComputerGuy wants to merge 12 commits intoNixOS:masterfrom
Conversation
33c476e to
2039bbf
Compare
97a57cc to
8f22062
Compare
|
So
|
|
Final goal is to provide cross compilation stdenv's which align with the pattern as described in #400351 (comment). These are purely the stdenv so eval will be smaller than bootstrapping another nixpkgs instance. As for |
|
Did a little benchmarking for musl on aarch64-linux.
|
8f22062 to
cc29572
Compare
cc29572 to
083aa05
Compare
448d600 to
b9e4dea
Compare
|
I just want to reiterate that things being called "cross" today is entirely tech debt and should be gotten rid of. I would really like @NixOS/stdenv to help out @cloudripper who has taken on my GCC repackaging, so we can get rid of that entirely. I would feel more comfortable doing this sort of change after that, because we'd be working atop a better foundation. |
b9e4dea to
1a513fc
Compare
1a513fc to
bb0d35d
Compare
Note that |
|
Is |
wolfgangwalther
left a comment
There was a problem hiding this comment.
Why call this crossStdenv and not provide these nice attributes on stdenv directly?
stdenv.for.config.wasi32-unknown-wasi
Avoids the term "cross".
| - A new cross compilation mechanism called `crossStdenv` has been added. It is recommended to use `crossStdenv` as | ||
| variants such as `pkgsCross`, `pkgsLLVM`, and `pkgsStatic` usage will no longer be permitted to be used in nixpkgs. |
There was a problem hiding this comment.
Although not used everywhere, yet, and unfortunately very hard to enforce via CI, we have a "one sentence per line" rule for docs:
Thus:
| - A new cross compilation mechanism called `crossStdenv` has been added. It is recommended to use `crossStdenv` as | |
| variants such as `pkgsCross`, `pkgsLLVM`, and `pkgsStatic` usage will no longer be permitted to be used in nixpkgs. | |
| - A new cross compilation mechanism called `crossStdenv` has been added. | |
| It is recommended to use `crossStdenv` as variants such as `pkgsCross`, `pkgsLLVM`, and `pkgsStatic` usage will no longer be permitted to be used in nixpkgs. |
| #### How do I cross compile in nixpkgs? {#cross-qa-cross-compile-in-nixpkgs} | ||
| Since NixOS 25.05, package sets such as `pkgsLLVM`, `pkgsMusl`, and `pkgsCross` have been moved into being labeled as variants. Future NixOS releases will disable the use of variants in nixpkgs. This is due to the increased evaluation since variants create a new nixpkgs instance atop the existing one. NixOS 24.11 introduces a feature called `crossStdenv`, this is a set of stdenv's for cross compiling without instantiating a new nixpkgs instance. `crossStdenv` contains a recursive attribute set called `predicated` and provides boolean options to a platform attribute set. It also contains `libcs` which is an attribute set of libc's that can be utilized. Finally, the recursive attribute set contains `configs` and `native`. `configs` is a set of attribute sets which contains stdenv's for each platform target that is supported for cross compiling. An example of the new pattern for something like `pkgsCross.wasi32.hello` would be: |
There was a problem hiding this comment.
Please use one sentence per line here, too, otherwise it's really hard to comment nicely on each sentence.
| #### How do I cross compile in nixpkgs? {#cross-qa-cross-compile-in-nixpkgs} | |
| Since NixOS 25.05, package sets such as `pkgsLLVM`, `pkgsMusl`, and `pkgsCross` have been moved into being labeled as variants. Future NixOS releases will disable the use of variants in nixpkgs. This is due to the increased evaluation since variants create a new nixpkgs instance atop the existing one. NixOS 24.11 introduces a feature called `crossStdenv`, this is a set of stdenv's for cross compiling without instantiating a new nixpkgs instance. `crossStdenv` contains a recursive attribute set called `predicated` and provides boolean options to a platform attribute set. It also contains `libcs` which is an attribute set of libc's that can be utilized. Finally, the recursive attribute set contains `configs` and `native`. `configs` is a set of attribute sets which contains stdenv's for each platform target that is supported for cross compiling. An example of the new pattern for something like `pkgsCross.wasi32.hello` would be: | |
| #### How do I cross compile in nixpkgs? {#cross-qa-cross-compile-in-nixpkgs} | |
| Since NixOS 25.05, package sets such as `pkgsLLVM`, `pkgsMusl`, and `pkgsCross` have been labeled as variants. Future NixOS releases will disallow the use of variants in nixpkgs. This is due to the increased evaluation time since each variant creates a new nixpkgs instance. NixOS 25.11 introduces `crossStdenv`, which is a set of stdenvs for cross compiling without instantiating a new nixpkgs instance. It contains a recursive attribute set `predicated` and provides boolean options to a platform attribute set. It also contains `libc` which is an attribute set of libcs that can be utilized. Finally, it contains `configs` and `native`. `configs` is a set of attribute sets which contains stdenvs for each platform target that is supported for cross compiling. An example of the new pattern for something like `pkgsCross.wasi32.hello` would be: |
(I put a few smaller changes in this, but it won't be highlighted due to everything being on one line here ... :/)
It mentions native but doesn't explain it.
| } | ||
| ``` | ||
|
|
||
| Note that the `stdenv` is overridden to provide the `wasi32-unknown-wasi` stdenv with the `useLLVM` predicate enabled. It is important to override all runtime dependencies to ensure the package properly cross compiles. |
There was a problem hiding this comment.
| Note that the `stdenv` is overridden to provide the `wasi32-unknown-wasi` stdenv with the `useLLVM` predicate enabled. It is important to override all runtime dependencies to ensure the package properly cross compiles. | |
| Note that `stdenv` is overridden to provide the `wasi32-unknown-wasi` stdenv with the `useLLVM` predicate enabled. | |
| It is important to override all runtime dependencies to ensure the package properly compiles. |
| "musl" | ||
| "glibc" | ||
| "newlib" | ||
| "newlib-nano" | ||
| "msvcrt" | ||
| "ucrt" |
There was a problem hiding this comment.
People will add stuff over time and it always confuses me. Where do I add this?
Might as well sort alphabetically instead of randomly:
| "musl" | |
| "glibc" | |
| "newlib" | |
| "newlib-nano" | |
| "msvcrt" | |
| "ucrt" | |
| "glibc" | |
| "msvcrt" | |
| "musl" | |
| "newlib" | |
| "newlib-nano" | |
| "ucrt" |
| predicates = [ | ||
| "useLLVM" | ||
| "isStatic" | ||
| ]; |
There was a problem hiding this comment.
| predicates = [ | |
| "useLLVM" | |
| "isStatic" | |
| ]; | |
| predicates = [ | |
| "isStatic" | |
| "useLLVM" | |
| ]; |
| configs = [ | ||
| "avr" | ||
| "aarch64-unknown-linux-gnu" | ||
| "aarch64-unknown-linux-musl" | ||
| "armv7l-unknown-linux-gnueabihf" | ||
| "arm-none-eabi" | ||
| "i686-unknown-linux-gnu" | ||
| "i686-w64-mingw32" | ||
| "s390-unknown-linux-gnu" | ||
| "s390x-unknown-linux-gnu" | ||
| "riscv32-unknown-linux-gnu" | ||
| "riscv32-unknown-linux-musl" | ||
| "riscv64-unknown-linux-gnu" | ||
| "riscv64-unknown-linux-musl" | ||
| "wasm32-unknown-none" | ||
| "wasm32-unknown-wasi" | ||
| "x86_64-unknown-linux-gnu" | ||
| "x86_64-unknown-linux-musl" | ||
| "x86_64-w64-mingw32" | ||
| ]; |
There was a problem hiding this comment.
| configs = [ | |
| "avr" | |
| "aarch64-unknown-linux-gnu" | |
| "aarch64-unknown-linux-musl" | |
| "armv7l-unknown-linux-gnueabihf" | |
| "arm-none-eabi" | |
| "i686-unknown-linux-gnu" | |
| "i686-w64-mingw32" | |
| "s390-unknown-linux-gnu" | |
| "s390x-unknown-linux-gnu" | |
| "riscv32-unknown-linux-gnu" | |
| "riscv32-unknown-linux-musl" | |
| "riscv64-unknown-linux-gnu" | |
| "riscv64-unknown-linux-musl" | |
| "wasm32-unknown-none" | |
| "wasm32-unknown-wasi" | |
| "x86_64-unknown-linux-gnu" | |
| "x86_64-unknown-linux-musl" | |
| "x86_64-w64-mingw32" | |
| ]; | |
| configs = [ | |
| "aarch64-unknown-linux-gnu" | |
| "aarch64-unknown-linux-musl" | |
| "arm-none-eabi" | |
| "armv7l-unknown-linux-gnueabihf" | |
| "avr" | |
| "i686-unknown-linux-gnu" | |
| "i686-w64-mingw32" | |
| "riscv32-unknown-linux-gnu" | |
| "riscv32-unknown-linux-musl" | |
| "riscv64-unknown-linux-gnu" | |
| "riscv64-unknown-linux-musl" | |
| "s390-unknown-linux-gnu" | |
| "s390x-unknown-linux-gnu" | |
| "wasm32-unknown-none" | |
| "wasm32-unknown-wasi" | |
| "x86_64-unknown-linux-gnu" | |
| "x86_64-unknown-linux-musl" | |
| "x86_64-w64-mingw32" | |
| ]; |
| configs = mkConfigSet platform; | ||
| predicated = mkPredicatedSet platform; | ||
| libc = mkLibcSet platform; | ||
| native = overrideStdenv ( |
There was a problem hiding this comment.
libc is singular (although the docs currently say libcs) and configs is plural.
We only select a single one at any given point, so I think both should be singular.
| configs = mkConfigSet platform; | |
| predicated = mkPredicatedSet platform; | |
| libc = mkLibcSet platform; | |
| native = overrideStdenv ( | |
| config = mkConfigSet platform; | |
| predicated = mkPredicatedSet platform; | |
| libc = mkLibcSet platform; | |
| native = overrideStdenv ( |
|
Tristan, this PR looks blocked on your response to feedback. I'm marking it as draft until you've got the cycles to unblock it. |
Things done
Adds the new
crossStdenvmechanism to be used inside nixpkgs instead of variants. Tested severalarmTrustedFirmwarederivations as they appear on search and they compile fine.nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.