Commit Graph

647 Commits

Author SHA1 Message Date
John Ericson
33589cc0c6 lib/systems: derive more platform metadata instead of restating it
`examples.nix` had settings that only repeated what the `config` already
implied. They read as if the platform were special, when it ought to be
the default. Now the default logic in `default.nix` ought to handle the
setting in question in a rule-based way so it is.

 Change:

- `useLLVM` now covers
  - UEFI
  - MSVC CRT and C++ ABI
  - Windows on AArch64 as well as FreeBSD and OpenBSD

- `libc` gains a UEFI case

hat retires seven `useLLVM` settings, eighteen `libc = "newlib"`, one
`libc = "bionic"`, and the `libc`/`linker` pair on the UEFI examples.

The remaining `libc`s in examples now means"this differs from what the
triple implies", which is true of the seven left: `newlib-nano`, the
mingw `msvcrt`/`ucrt` pairs those entries exist to distinguish, and
`mmix`, whose OS is `mmixware` rather than `none` so the bare-metal
default does not reach it. That one gains a comment.

No functional change. Elaborating all 87 platforms in
`lib.systems.examples` before and after gives byte-identical `config`,
`system`, `useLLVM`, `useGccNG`, `libc`, `linker` and
`rust.rustcTarget`. `mmix` surfaced that way, having regressed to
`native/impure`.

Assisted-by: Claude Code (Claude Opus 5)
2026-08-12 19:38:22 -04:00
John Ericson
92144940a3 gcc/ng: let a platform opt in with useGccNG
Nothing could select the split GCC package set, so none of the fixes
below this commit were reachable from a normal build.

Add `useGccNG` alongside the existing `useLLVM`/`useZig`/`useArocc`
choices, and honour it where a compiler is picked: the cross stdenv takes
`gccNGPackages.gcc`, and `stdenvNoLibs`/`stdenvNoLibc` map to
`gccNoLibgcc` and `gccWithLibgcc`. That last pair is the point of the
split. Both currently fall back to `gccCrossLibcStdenv`, because the
monolithic compiler cannot distinguish them; `lib/systems/default.nix`
says as much next to `linker`, noting that we would like to choose the C
compiler and runtime library orthogonally but "due to the monolithic GCC
build we cannot actually make those choices independently". This is what
lifts that, the way the LLVM set already splits `clangNoCompilerRt` from
`clangNoLibc`.

`gccNGPackages` tracks `default-gcc-version` rather than naming a
release, so the split set and the monolithic `gcc` stay on the same one.

`useGccNG` defaults to `false` and no platform derives it, so no existing
build changes. Setting it on a platform spec is enough to exercise the
whole stack:

    nix-build . -A stdenv.cc --arg crossSystem \
      '{ config = "aarch64-unknown-linux-musl"; useGccNG = true; }'

The intent is to switch obscure low-tier platforms over to it soon --
NetBSD first -- so `ng` gets dogfooded somewhere the blast radius is
small. Those switches come separately.

Assisted-by: Claude Code (Claude Opus 5)
2026-08-12 16:46:18 -04:00
Artemis Tosini
c41cd7fd36 lib.systems: add GOARCH for big-endian mips64 (#539363) 2026-08-03 15:19:39 +00:00
·𐑑𐑴𐑕𐑑𐑩𐑤
5241238f68 lib/systems: add picolibc 2026-07-28 22:33:36 -07:00
Sam Pointon
bd6051aa5f systems: also rename pkgsCross.wasi32, leaving aliases 2026-07-28 19:50:03 +01:00
Sam Pointon
629b4ee093 systems: rename extant wasi targets to wasip1
Wasi P2 is different enough to Wasi P1 to warrant being treated entirely 
separately, rather than as two minor variants of the same thing. P3 will 
likewise want to be a different target.

I've left aliases in place; maybe eventually, those can be deprecated 
and removed. I've tested this, but it's possible there might be breakage 
somewhere (e.g., the canonical doubles for P1 have changed, though I 
can't imagine why anyone would rely on that).

Fixes https://github.com/NixOS/nixpkgs/issues/435954
2026-07-28 19:50:03 +01:00
Eman Resu
d55c01c37d lib/systems/inspect: partially apply hasPrefix 2026-07-20 10:29:40 -04:00
Amaan Qureshi
7e81743aa6 lib.systems: add GOARCH for big-endian mips64 2026-07-07 15:30:40 -04:00
Eman Resu
25a7ae8e4c lib.platforms: move primary systems to the beginning of the list 2026-07-04 09:36:48 -04:00
Emily
bd83232593 lib/systems/doubles: drop x86_64-darwin
This ensures that `lib.platforms.darwin` doesn’t include
`x86_64-darwin` and that the unsupported platform check will trigger
even once the bespoke deprecation error is removed. It doesn’t break
`lib.systems.elaborate "x86_64-darwin"`.
2026-06-21 19:37:17 +01:00
Emily
41341de669 lib/systems/examples: drop x86_64-darwin 2026-06-21 19:37:17 +01:00
Emily
c6adddfbc2 lib/systems/flake-systems: drop x86_64-darwin 2026-06-21 19:22:33 +01:00
Eman Resu
add81e270c lib.systems.doubles: only typecheck in CI 2026-06-20 17:05:35 -04:00
Eman Resu
0bc9fb54a4 lib.systems.parse: avoid toString if no version specified 2026-06-20 17:05:35 -04:00
Eman Resu
38816ea2a3 lib.systems.inspect: save memory when removing attributes 2026-06-20 17:05:35 -04:00
Eman Resu
6e37f410ad lib.systems.parse: avoid redefining component lists 2026-06-20 17:05:35 -04:00
Eman Resu
14da2748d2 lib.systems.parse: define variables for components 2026-06-20 17:05:34 -04:00
Eman Resu
c344980c19 lib.systems.parse: avoid some function calls 2026-06-20 17:05:34 -04:00
Eman Resu
753e3defc2 lib.systems.parse: inherit verification functions 2026-06-20 17:05:34 -04:00
Eman Resu
792207ab34 lib.systems.parse: rewrite to use meta-types 2026-06-20 17:05:34 -04:00
Eman Resu
c5cb2f465c lib.systems: cache attrNames calls for each pattern 2026-06-20 17:05:30 -04:00
Eman Resu
88d7ba7fc7 lib.systems: only run isAttrs on one side when recursing 2026-06-20 17:05:16 -04:00
Eman Resu
d65d6f570f lib.systems: define matchAttrs locally
Skipping the assertion.
2026-06-20 17:05:14 -04:00
Eman Resu
0cadcfb613 lib.systems: define let variables outside of function 2026-06-20 16:53:32 -04:00
Matt Sturgeon
437220a111 lib/systems: gate linux-kernel assertion behind oldestSupportedRelease (#532194) 2026-06-17 11:44:55 +00:00
Matt Sturgeon
f5f59e0c4a lib/systems: gate linux-kernel assertion behind oldestSupportedRelease
A platform elaborated by another supported revision of Nixpkgs would
trip the assertion when it is re-elaborated.

Avoid this, by checking `oldestSupportedReleaseIsAtLeast 2511`, as 25.11
is the version that stopped adding `linux-kernel` to elaborated systems.
2026-06-16 06:43:14 +01:00
Sam Pointon
4a3079eda3 systems: set rust.platform.env as rustc does
rustc allows code to perform compile-time tests against target_env [0], 
which is a function of the target triple. There isn't provision in 
Nixpkgs for learning target_env, however. That doesn't affect rustc's 
evaluation of cfg guards in Rust code - rustc knows perfectly well what 
target_env is - but it _does_ affect the env vars passed to a build 
script set by buildRustCrate, which is presently hard-coded to gnu, and 
also affects any Nix code looking to branch on target_env.

Being able to access target_env is very relevant to, for example, WASI 
as (using Rust terminology) wasm32-wasip1 and wasm32-wasip2 differ only 
by target_env, with identical target_arch and target_os values. Properly 
reflecting target_env may also fix some random musl issues if you're a 
bit lucky.

This commit adds a new attr, rust.platform.env, which reflects the 
target_env that rustc will set for the target, and wires it up in 
buildRustCrate. In isolation, this change mostly only affects build 
scripts checking target_env, but crate2nix will greatly benefit from 
being able to accurately resolve the dep graph (which can also vary 
depending on target_env).

The target triple -> target_env function resists Kolmogorov compression: 
it's irregular and, though there are some patterns, there are lots of 
special cases. So, I have done the stupidest possible thing and scraped 
out all of the targets with non-empty target_env values and dumped that 
into an attrset. This attrset will progressively get out of date as 
rustc adds new platforms, but updating it should be simple enough - I've 
included the generation script as a comment.

There are some other configuration options not being reflected in Nix. I 
have left those alone, but, in the future, maybe this can be extended to 
just dumping all of them into an attrset and then reflecting them in 
rust.platform. It might even make sense to convert the existing code 
producing rust.platform to just looking up from an attrset and to 'do 
what rustc does'.

I would have liked to have added a test targetting a platform with a 
non-empty non-GNU target_env, but all of the yaks were quite hairy.

Fixes https://github.com/NixOS/nixpkgs/issues/436832

[0]: https://doc.rust-lang.org/reference/conditional-compilation.html#r-cfg.target_env
2026-06-15 16:21:13 +01:00
Emily
31d1d80b3f lib/systems: move kernel configuration out of the platform structure
Currently, you need to override `stdenv.hostPlatform` to request a
compressed kernel on AArch64, and the kernel configuration is split
between the central structured configuration and string snippets in
platform definitions. This has consequently made the latter bitrot
terribly. Since the platform‐specific logic is now very limited after
cleaning up the detritus, we can move it into the kernel derivation
and expose the relevant configuration there for anyone who wants to
customize it further or needs to read it out.

Co-authored-by: zowoq <59103226+zowoq@users.noreply.github.com>
2026-06-10 11:17:38 +10:00
zowoq
9497b712f6 linux/common-config: move USB_XHCI_TEGRA from lib/systems aarch64-multiplatform
Co-authored-by: Emily <vcs@emily.moe>
2026-06-08 18:05:35 +10:00
Emily
0c19eb3e55 lib/systems: unify ARMv5 platforms with stock kernel configuration
The `sheevaplug` kernel configuration was added a very long time
ago and has not been adjusted for years. `pogoplug4` was identical
to `sheevaplug` except for an even more stripped‐down kernel
configuration, no device tree support, and a different load address
for the uImage.

These days, the stock kernel configuration builds and there has been
an upstream device tree for the Pogoplug Series 4 for years; unify
`sheevaplug` and `pogoplug4` into an `armv5tel-multiplatform` that
uses the standard configuration.

ARMv5 was also the only platform that defaulted to uImage, the [legacy
U‐Boot image format] that is deprecated upstream. Our bootloader
machinery in NixOS does not handle these images in any special way
and even the original ARMv6 Raspberry Pi platform defaults to the
standard zImage. We switch `armv5tel-multiplatform` to zImage to match.

[legacy U‐Boot image format]: https://docs.u-boot.org/en/latest/usage/cmd/bootm.html#legacy-boot

It is of course natural to worry about backwards compatibility
here: this switches to a different kernel image format and drops
support for root on NFS along with random oddities like KGDB and
LatencyTOP. Renaming the platform is intended to help mitigate
this risk.

The reality, however, is that it is currently very
difficult to build a configuration for ARMv5. I found
<https://github.com/thefloweringash/sheevaplug-nix> online as
an example configuration from many years ago; it already set
`autoModules`, and builds U‐Boot using `CONFIG_DISTRO_DEFAULTS`,
which should work out of the box without requiring the legacy U‐Boot
image format.

Even then, however, I confirmed with the author that it hasn’t
been used in years, and I could barely get it to build with
a modern Nixpkgs: OpenSSH is broken, Nix is broken, multiple
default `environment.systemPackages` in the SD image profile
are broken, `boot.initrd.includeDefaultModules` is broken, and
`hardware.enableAllHardware` is broken.

I conclude that if anyone is actively building systems on ARMv5, they
have a forked Nixpkgs or a very custom setup. Given our general move
to standard boot chains and no platform‐specific hacks, and the
decaying state of our unofficial support for 32‐bit ARM, I think
it is not worth maintaining support for the legacy image format for
this one ancient platform.

If anyone is running a heavily stripped‐down NixOS configuration on
mission‐critical SheevaPlugs using a custom Nix‐free deployment
setup relying on the legacy U‐Boot image format and somehow none
of these kernel changes manage to loudly break their build, hopefully
they’ll at least notice the release notes entry! Otherwise there’s
always JTAG…
2026-06-01 11:12:17 +10:00
Emily
af6485561c lib/systems: remove unused platforms
These were not used by the selection logic or
`lib/systems/examples.nix`, so any consumer would have to be including
them explicitly. Since we’re moving away from setting Linux kernel
configuration in the platform structure, breaking these explictily
won’t reduce the convenience and will help signal to any such expert
users that they need to move their kernel configuration elsewhere.
2026-06-01 11:12:17 +10:00
Emily
9c5ca61078 lib/systems: remove broken kernel configurations
None of these successfully build a kernel, and as we’re moving
away from putting kernel configuration in the platform structure and
don’t package the vendor kernels that all but `fuloong2f_n32` expect,
there’s no point to keeping these kernel configurations in Nixpkgs.
2026-06-01 11:12:17 +10:00
Emily
d408bc4f02 lib/systems: remove obsolete KS8851_MLL workaround
This was fixed by 51bb08dd04a05035a64504faa47651d36b0f3125 upstream,
which is in all our supported kernels ≥ 5.12.
2026-06-01 11:12:17 +10:00
Emily
c76c290c14 lib/systems: remove redundant kernel configuration
These are now already set upstream and should result in no change,
even for the Raspberry Pi vendor kernels.
2026-06-01 11:12:17 +10:00
Emily
53f91beef8 lib/systems: remove unused linux-kernel.Major field 2026-06-01 11:12:17 +10:00
Emily
b59952e523 lib/systems: don’t specify multi_v7_defconfig explicitly
This has been the default for `defconfig` upstream since
32872c04ffd5a855c43802c5aa76c711eb021948, which is in all our
supported kernels.
2026-06-01 11:12:17 +10:00
Emily
1c935b9fd9 lib/systems: drop gnu64_simplekernel
This was unused apart from a commented‐out test, and we’re moving
away from specifying kernel configuration in the platform structure.
2026-05-30 14:12:51 +10:00
Emily
ba777b3b20 lib.systems.equals: fix euqality on re-elaborated platform (#521043) 2026-05-16 18:39:00 +00:00
Mix
cadca751c4 lib.systems.equals: fix euqality on re-elaborated platform 2026-05-17 02:14:48 +08:00
adisbladis
5a4597cc83 lib.systems: foldl -> foldl' 2026-05-16 15:51:29 +12:00
Emily
036199b38a lib.systems.equals: only filter functions once (#513844) 2026-05-13 00:56:58 +00:00
eveeifyeve
a8f0a99212 nim: deprecate and move os and cpu to stdenv.targetPlatform.nim
This change makes it more accesssable to using nim cpu and os without
referencing nim.
2026-05-06 22:29:23 +10:00
Alyssa Ross
a58377983f lib.systems: various small performance improvements (#514493) 2026-05-04 08:15:54 +00:00
Eman Resu
acd5585a3b lib.systems.parse: check if cpus are equal first
Rather than doing this last, we do it first. Saves a little time if
we're comparing to an identical platform
2026-05-03 16:49:37 -04:00
Eman Resu
833f05d099 lib.systems.elaborate: prevent unnecessary attrset merges 2026-05-03 08:04:34 -04:00
Eman Resu
a9c0a094f7 lib.systems.elaborate: avoid optionalAttrs merge 2026-05-03 08:04:34 -04:00
Eman Resu
7fcbff801d lib.systems.parse: only check condition once 2026-05-03 08:04:33 -04:00
Eman Resu
577b481774 lib.systems.parse: use builtins.head foo instead of elemAt foo 0 2026-05-03 08:04:28 -04:00
Rasheeq Azad
29101432aa lib.systems.architectures: add rocketlake 2026-05-02 18:47:17 -04:00
Eman Resu
0f0f29fcf1 lib/systems: store version of elaborated system without functions 2026-04-26 23:56:51 -04:00