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.
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
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>
Scope:
- Combination of
- Textual matches of "baseNameOf (toString"
- Redundant toString calls I've found with my latest
"lazy paths" nix branch as they force lazy fetches into
the store. More info and new PR soon.
- Only cases I believe are worthwhile or easily determined
I've determined the validity by
- testing llvmPackages instantiation
- figuring out which types can pass into any particular
toString call - "human fuzzy type checker"
Behavior considerations by type:
- `path`: converted back to a string *without* context
`baseNameOf` does not copy things to the store on its own,
equivalent to its behavior for string inputs
- `null`: converted to `""` -> may be valid input!
ok if "" would not have been acceptable anyway
- `string` itself: passed through identically -> trivial
- `attrset` with `outPath`: same coercion as built into
the `baseNameOf` function -> trivial
- other atomic types: generally not sensible inputs to
`baseNameOf` -> fuzzy but true
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…
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.
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.
warnIf sends our warning message through a function call, even if the
warning condition doesn't trigger. This requires a lot of thunk
allocation that can be easily avoided.
- Improve extractItem error messages: distinguish non-attrset elements
from multi-key attrsets, and include the faulty definition via showDefs.
- Use isType instead of raw _type access for order detection.
- Disable type merging (typeMerge = t: null) instead of providing a
functor-based merge. Add test confirming duplicate declarations fail.
This allows the type's return value to be accessed more easily.
Motivating use case:
- Built-in module provides CLI functionality by declaring
an `attrListWith { asAttrs = true; }`, extracting the ordered list
from `valueMeta` for the purpose of creating the `argv`.
- User modules can read the command line's flags directly without
having to parse the list of attrs.
This adds a type for name-value mappings that preserve ordering.
Motivating use case: command line flags for package modules /
wrappers / modular services.
The option value can be transformed into a command line in the
correct order.
Additionally, a convenience readOnly option could be provided
to give easy introspection access to the values in an ad hoc
manner.
Seems preferable to iterating over a two-element list.
licenseType.exception is only used by lib.licenses.WITH, which I don't
see any usage of in tree - but thought I might as well.