5093 Commits
Author SHA1 Message Date
Matt SturgeonandGitHub 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
Johannes KirschbauerandGitHub 6c0202028d lib.attrsets.mergeAttrsList: small arithmetic performance improvements (#528677) 2026-06-11 15:01:53 +00:00
Johannes Kirschbauer 0cb9aa055c lib/types: remove functor.wrapped after deprecation phase of 2 full releases 2026-06-10 21:24:53 +02:00
Eman Resu 2d99119aa0 lib.attrsets.mergeAttrsList: check equality instead of comparing 2026-06-10 12:22:39 -04:00
Emilyandzowoq 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
zowoqandEmily 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
Eman Resu dd16d43a35 lib.attrsets.mergeAttrsList: use simpler midpoint function 2026-06-06 02:42:26 -04:00
Robert Hensing 235013cf37 treewide: drop unnecessary toString calls
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
2026-06-04 13:11:56 +02:00
Emilyandzowoq 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
Emilyandzowoq 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
Emilyandzowoq 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
Emilyandzowoq 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
Emilyandzowoq 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
Emilyandzowoq 53f91beef8 lib/systems: remove unused linux-kernel.Major field 2026-06-01 11:12:17 +10:00
Emilyandzowoq 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
Emilyandzowoq 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
YtandGitHub a26e677695 python3Packages.emmiai-noether: init at 2026.4.0 (#525203) 2026-05-28 16:28:27 +00:00
Philip TaronandGitHub 19bd880f94 various: remove lib.warnIf from most critical functions (#524541) 2026-05-28 15:50:31 +00:00
SandroandGitHub 489cd7957b netboxPlugins.netbox-custom-objects: init at 0.5.1 (#523936) 2026-05-28 12:55:58 +00:00
Gaetan Lepage 8396e4b976 licenses: add enpl, Emmi AI Non-Production License 2026-05-28 12:41:55 +00:00
adisbladisandGitHub c0d82318ed lib.generators.toGitINI: performance improvements (#522818) 2026-05-28 06:27:54 +00:00
Eman Resu 3ec1e90b10 lib/modules: remove warnIf usage
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.
2026-05-28 00:19:32 -04:00
Philip TaronandGitHub e03d0a783d various: reduce // merges, optimize ++ chains across hot paths (#506793) 2026-05-27 22:06:37 +00:00
Nico Felbinger 405f08f765 licenses: init netboxLimitedUse 2026-05-27 18:39:06 +02:00
zimbatmandadisbladis 01bdc186ae lib.sources.sourceByGlobs: address review comments 2026-05-26 21:49:00 +12:00
adisbladis 59d55cbaa3 lib.sources.sourceByGlobs: init function
Adds a source filtering function inspired by [doublestar](https://github.com/bmatcuk/doublestar).

This has been in used in a few private repositories since the last ~6 months with success.

- Testing

This was originally tested with the nix-unit testsuite:
```
let
  inherit (import ./internal.nix) mkSourceFilter mkMatcher;
in
{
  mkMatcher = {
    empty = {
      testMatch = {
        expr = mkMatcher "" "" "regular";
        expected = true;
      };

      testNoMatch = {
        expr = mkMatcher "" "foo" "regular";
        expected = false;
      };
    };

    simple = {
      testMatch = {
        expr = mkMatcher "foo" "foo" "regular";
        expected = true;
      };

      testNoMatch = {
        expr = mkMatcher "foo" "bar" "regular";
        expected = false;
      };
    };

    singleStar = {
      testMatch = {
        expr = mkMatcher "*.js" "foo.js" "regular";
        expected = true;
      };

      testNoMatch = {
        expr = mkMatcher "*.js" "foo.py" "regular";
        expected = false;
      };
    };

    doubleStar = {
      testMatch = {
        expr = mkMatcher "foo/**/bar" "foo/baz/bar" "regular";
        expected = true;
      };

      testNoMatch = {
        expr = mkMatcher "foo/**/bar" "foo/bar/baz" "regular";
        expected = false;
      };

      testMultiMatch = {
        expr = mkMatcher "foo/**/bar" "foo/baz/xyz/bar" "regular";
        expected = true;
      };

      testMultiMatchDoubleGlob = {
        expr = mkMatcher "foo/**/**/bar" "foo/baz/xyz/bar" "regular";
        expected = true;
      };

      testInfixMatch = {
        expr = mkMatcher "foo/**/qux/**/bar" "foo/baz/qux/baz/bar" "regular";
        expected = true;
      };

      testInfixNoMatch = {
        expr = mkMatcher "foo/**/xyz/**/bar" "foo/baz/qux/baz/bar" "regular";
        expected = false;
      };

      # Technically a partial match
      testInfixDirMatch = {
        expr = mkMatcher "foo/**/xyz/**/bar" "foo/baz/qux/baz/bar" "directory";
        expected = true;
      };
    };
  };

  mkSourceFilter = {
    testSourceFilter = {
      expr = mkSourceFilter ./fixtures [
        "bar/*.js"
      ] "bar/bar.js" "regular";
      expected = true;
    };
  };
}
```
but it was dropped in this nixpkgs contribution as the structure of nixpkgs lib testing is too primitive to incorp this without more extensive refactoring than I'd like at the momment.

- Performance

It's hard to benchmark this against anything else meaningful except [globsset](https://github.com/pdtpartners/globset), which has a very similar API.

`sourceByGlobs` avoids performance pitfalls by:

  - Using `builtins.filterSource`

      This is more performant than the fileset API.
      The downside compared to the fileset API is that any directory which matches the filter will be added to the build, even if it's empty.

  - Match paths component by component

      By splitting each pattern into a token per / separator.
      This is much faster in Nix than the doublestar algorithm.

- Globset source

```json
{
    "cpuTime": 0.8585879802703857,
    "envs": {
        "bytes": 148252864,
        "elements": 11899843,
        "number": 6631765
    },
    "gc": {
        "heapSize": 402915328,
        "totalBytes": 671288560
    },
    "list": {
        "bytes": 3358664,
        "concats": 28658,
        "elements": 419833
    },
    "nrAvoided": 11562713,
    "nrFunctionCalls": 4816963,
    "nrLookups": 4316209,
    "nrOpUpdateValuesCopied": 5686407,
    "nrOpUpdates": 464060,
    "nrPrimOpCalls": 2966970,
    "nrThunks": 7796186,
    "sets": {
        "bytes": 196404672,
        "elements": 10837802,
        "number": 1437490
    },
    "sizes": {
        "Attr": 16,
        "Bindings": 16,
        "Env": 8,
        "Value": 24
    },
    "symbols": {
        "bytes": 340652,
        "number": 32026
    },
    "values": {
        "bytes": 207367440,
        "number": 8640310
    }
}
```

- Glob-filter source

```json
{
    "cpuTime": 0.3904629945755005,
    "envs": {
        "bytes": 13263440,
        "elements": 1005877,
        "number": 652053
    },
    "gc": {
        "heapSize": 402915328,
        "totalBytes": 146914896
    },
    "list": {
        "bytes": 3032168,
        "concats": 5899,
        "elements": 379021
    },
    "nrAvoided": 1666598,
    "nrFunctionCalls": 484399,
    "nrLookups": 112698,
    "nrOpUpdateValuesCopied": 3432135,
    "nrOpUpdates": 13426,
    "nrPrimOpCalls": 1041954,
    "nrThunks": 1205792,
    "sets": {
        "bytes": 64304800,
        "elements": 3978167,
        "number": 40883
    },
    "sizes": {
        "Attr": 16,
        "Bindings": 16,
        "Env": 8,
        "Value": 24
    },
    "symbols": {
        "bytes": 285306,
        "number": 28864
    },
    "values": {
        "bytes": 42963240,
        "number": 1790135
    }
}
```
2026-05-26 21:48:59 +12:00
Robert HensingandGitHub ccbf6da64e types.attrList: init (#510698) 2026-05-25 11:34:46 +00:00
Johannes Kirschbauer ae142b5738 types.attrListWith: review fixes
- 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.
2026-05-24 15:32:04 +02:00
Robert HensingandJohannes Kirschbauer 8aa6e3dbb9 types.attrListWith: add valueMeta.definitions 2026-05-24 15:32:04 +02:00
Robert HensingandJohannes Kirschbauer e29bf2412b lib.modules.mapDefinitionValue: init 2026-05-24 15:32:04 +02:00
yaya a2e55e31d6 26.11 is Zokor 2026-05-24 15:07:40 +02:00
Robert HensingandJohannes Kirschbauer f1b62fdc4e types.attrListWith: add asAttrs
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.
2026-05-24 15:07:05 +02:00
Robert HensingandJohannes Kirschbauer 17fdb6f68a types.attrListWith: init
Trivial extraction from attrListOf.
2026-05-24 15:07:05 +02:00
Robert HensingandJohannes Kirschbauer 43d998e6c0 types.attrListOf: init
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.
2026-05-24 15:07:02 +02:00
Eman Resu e9c2828c5a lib.generators.toGitINI: only recurse into necessary attributes 2026-05-21 18:16:47 -04:00
Eman Resu ad02f2310f lib.generators.toGitINI: use concatMap to avoid a flatten at the end 2026-05-21 16:17:59 -04:00
Eman Resu 69bb729396 lib.generators.toGitINI: avoid concatenating and mapping on non-lists 2026-05-21 16:15:45 -04:00
Eman Resu 9b4dde7eba lib.generators.toGitINI: move escape logic outside of hot loop 2026-05-21 16:15:45 -04:00
Eman Resu af62ce4887 lib.generators.toGitINI: avoid creating several variables on every call 2026-05-21 16:15:45 -04:00
Eman Resu 48a99a99fc lib.generators.toGitINI: only define helper variables once 2026-05-21 16:15:24 -04:00
Eman Resu f23b117e50 lib.showWarnings: inherit lib functions, beta reduce for free 2026-05-21 14:50:51 -04:00
Eman Resu 7f6eb89aeb lib.{importJSON,importTOML}: inherit builtins to global scope 2026-05-21 14:47:07 -04:00
Eman Resu 1f83c2cc22 lib.toBaseDigits: avoid reversing list 2026-05-21 14:41:38 -04:00
Eman Resu 19fcf5006a lib.mirrorFunctionArgs: inline call to setFunctionArgs 2026-05-21 14:41:38 -04:00
adisbladisandGitHub 8abecec2ab lib.extendMkDerivation: performance cleanups (#522123) 2026-05-21 02:48:31 +00:00
adisbladisandGitHub 8efcb39ab2 lib.fetchers: minor performance improvements (#522121) 2026-05-21 02:46:56 +00:00
Eman Resu 32a1903229 lib.licenses: inherit lib functions into global scope 2026-05-20 00:32:15 -04:00
Eman Resu 1883329515 lib.licenses: use && for exception licenses
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.
2026-05-20 00:32:15 -04:00