5083 Commits

Author SHA1 Message Date
Eman Resu
a72cd26ceb lib.makeOverridable: avoid some function calls 2026-05-03 08:23:26 -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
Nick Cao
ba4edac0a4 lib.licenses: add DocBook DTD License 2026-05-02 08:45:24 -04:00
Michael Daniels
18e82c4591 lib: remove unused let bindings and args@{} uses 2026-04-30 18:43:56 -04:00
Eman Resu
3227158021 lib.meta.availableOn: move negation outside loop
Also exit early without meta.badPlatforms. This is a very hot function
thanks to its usage in stdenv check-meta.
2026-04-29 09:00:26 -04:00
Matt Sturgeon
986cb78f05 Reapply "lib/strings.concatLines: call concatStringsSep directly"
But also handle empty lists.

This effectively reapplies commit d7e6988c9b
which was reverted by commit 66f4e5d988.

Co-authored-by: Eman Resu <78693624+quatquatt@users.noreply.github.com>
2026-04-28 20:19:04 +01:00
Eman Resu
cb1edb8183 lib.makeOverridable: inline helper function into its usages
Also perform some manual beta reductions.
2026-04-28 13:59:32 -04:00
Eman Resu
c33811716d lib.makeOverridable: avoid optionalAttrs merge 2026-04-28 13:59:32 -04:00
Eman Resu
1e022acbf5 lib.makeOverridable: inline several variables 2026-04-28 13:59:32 -04:00
Eman Resu
8ccea3bf6c lib.extendDerivation: avoid optionalAttrs merge 2026-04-28 13:59:32 -04:00
Eman Resu
6325e7ff14 lib.extendDerivation: inline variables 2026-04-28 13:59:31 -04:00
Robert Hensing
629f0f2c6c lib/filesystem: remove absolute path literals (#514225) 2026-04-28 15:48:47 +00:00
John Ericson
fad35427aa lib/sources: remove absolute path literals (#514226) 2026-04-28 14:22:35 +00:00
Johannes Kirschbauer
5c9f6077a7 lib/concatLines: add test for empty list 2026-04-28 10:08:32 +02:00
Johannes Kirschbauer
66f4e5d988 Revert "lib/strings.concatLines: call concatStringsSep directly"
This reverts commit d7e6988c9b.
2026-04-28 10:04:39 +02:00
Ameer Taweel
ecf55714fe lib/sources: remove absolute path literals 2026-04-28 01:00:25 +03:00
Ameer Taweel
c6e1981fa2 lib/filesystem: remove absolute path literals 2026-04-28 00:59:06 +03:00
Eman Resu
0f0f29fcf1 lib/systems: store version of elaborated system without functions 2026-04-26 23:56:51 -04:00
Eman Resu
590d99ed5f lib/systems: remove old isCompatible 2026-04-26 22:14:48 -04:00
Johannes Kirschbauer
5d7c257e33 lib/services: improve configure function documentation (#508211) 2026-04-25 21:07:57 +00:00
jopejoe1
2b7f24eeb8 lib.licenses: add mpich2 2026-04-23 15:19:58 +02:00
Ben Siraphob
0f420e96c4 gcc, libgcc: fix cross-compilation for SH4
- Pass --with-multilib-list=m4,m4-nofpu for SH4 so the kernel can use
  -m4-nofpu. Move libraries out of !m4/ multilib subdirectory in
  postInstall before moveToOutput.
- Generate sysroot-suffix.h for SH4 in the standalone libgcc builder.
- Add linux-kernel.target = "vmlinux" and installTarget for SH4.

All changes scoped to isSh4 to avoid rebuilds on other platforms.
2026-04-20 13:02:20 -07:00
Ben Siraphob
0fcb031c25 lib/systems: add SH4 (SuperH) cross-compilation target
Add sh4 CPU type (32-bit, little-endian, family "sh"), isSh4 predicate,
"sh4-linux" system double, cross-compilation example (sh4-unknown-linux-gnu),
linuxArch mapping to "sh", and test entry.
2026-04-20 13:02:20 -07:00
Alyssa Ross
c27781ea44 lib.licenses: add universalFOSSException-10 (#511720) 2026-04-20 11:47:53 +00:00
jopejoe1
f8bcedf147 lib.licenses: add universalFOSSException-10 2026-04-20 13:35:06 +02:00
Robert Hensing
77b5864637 lib.modules: submodule emptyValue must evaluate sub-option defaults
`emptyValue` for `types.submodule` was `{ value = { }; }`, i.e. none
of the type-declared options or their defaults.

Previously submodules without defs would simply fail for lack of a default,
but since PR #500104 repurposed `emptyValue` as the fallback when no
definitions exist, submodule options without an explicit `default = { }`
(new additions) silently lost their sub-option defaults
(e.g. `requiredFeatures.devnet` in the nixos-test-driver, #511413).

Main change: `emptyValue`: `{ }` -> `{ value = base.config; }`

Additionally, skip `emptyValue`-based default rendering in docs for
types with submodules, because their sub-options are already documented
individually, and forcing evaluation here can break on modules with
invalid or incomplete definitions.
2026-04-19 20:52:33 +01:00
Robert Hensing
3a1a279cf8 lib/modules: reduce allocations in evalModules and mergeModules (#510048) 2026-04-19 17:21:54 +00:00
Ben Siraphob
b787ee3d40 lib/modules: reduce allocations in evalModules and mergeModules
- When `evalModules` is called without deprecated `args`/`check` parameters (the common case), avoid `modules ++ []` which copies the entire module list for no reason.
- `collectModules` was calling `collectStructuredModules` twice with identical arguments — once for `filterModules` and once for `toGraph`. Share the result via a `let` binding.
- Replace `zipAttrsWith (n: v: v)` with `zipAttrs`
- Replace `concatMap` with `filter`+`map` in `filterOverrides'`

NixOS minimal eval improvement: -5.0% list_concats, -1.2%
nrFunctionCalls, -0.7% nrThunks, -1.0% envs, -1.5% list_bytes.
2026-04-19 09:52:40 -07:00
jopejoe1
dbdb37908f lib/tests: add tests for lib.licenses 2026-04-19 12:22:11 +02:00
jopejoe1
bb8e1c54e9 lib.licenses: add compound licenses 2026-04-19 12:22:11 +02:00
Alyssa Ross
7251a763b7 lib/systems: fix incorrect CPU compatibility claims in isCompatible (#509796) 2026-04-19 09:44:23 +00:00
Johannes Kirschbauer
51f38b40cd lib/strings.concatLines: call concatStringsSep directly (#506077) 2026-04-16 19:32:28 +00:00
Alyssa Ross
4cd3a0ec79 lib/systems: add ARC cross-compilation target (#510160) 2026-04-15 15:51:26 +00:00
Ben Siraphob
6152e8cbfa lib/systems: add ARC (Synopsys DesignWare ARC) cross-compilation support
Add arc CPU type (32-bit, little-endian, family "arc"), isArc
predicate, arc-linux double, arc cross example with
arc-unknown-linux-gnu triple, and release-cross job.

ARC has glibc support and uses the "arc" Linux kernel arch, which
matches the CPU name so no explicit linuxArch mapping is needed.
2026-04-14 13:51:11 -07:00
Ben Siraphob
67c22bba37 lib/modules: skip optional + ++ in evalOptionValue when no default (#510028) 2026-04-14 17:42:41 +00:00
Ben Siraphob
1bec8475a6 lib/modules: skip optional + ++ in evalOptionValue when no default
Replace `(optional (opt ? default) { ... }) ++ defs` with a direct
if/then/else. When the option has no default, this skips both the
list allocation and the ++ concat entirely. Most options do have
defaults, but even then we avoid the `optional` function call overhead
(closure + env allocation).

On NixOS minimal eval: -45K function calls (-0.93%), -3.7K list
concats (-1.93%).
2026-04-14 10:25:34 -07:00
Jörg Thalheim
03796993b6 lib/modules: short-circuit mergeDefinitions for plain singletons (#509195) 2026-04-14 09:39:45 +00:00
Johannes Kirschbauer
dbe18bc16d lib.types.defaultTypeMerge: Fix for functors with no wrapped attr (#476219) 2026-04-14 07:15:44 +00:00
Ben Siraphob
34109687c7 lib/systems: fix incorrect CPU compatibility claims in isCompatible
Fix several incorrect backward-compatibility claims in the isCompatible
relation that do not reflect actual hardware/spec capabilities.

- armv6m: Reverse direction. ARMv6-M (Cortex-M0) is Thumb-only and
  cannot run full ARMv6 ARM-state code; armv6m code runs on armv6l.
  https://developer.arm.com/documentation/ddi0432/latest/programmers-model/instruction-set-summary

- armv7m: ARMv7-M (Cortex-M3/M4) is Thumb-2 only, cannot run ARM-state
  armv7l code. armv7a/armv7r (which have ARM-state) can run armv7m code.
  https://developer.arm.com/documentation/ddi0403/d/Application-Level-Architecture/The-ARMv7-M-Instruction-Set/About-the-instruction-set

- armv8m: Remove armv8m->armv8a. ARMv8-M is Thumb-only M-profile with
  incompatible system registers and exception model.

- aarch64<->armv8a: Remove bidirectional equivalence. AArch32 cannot
  execute A64 instructions. Keep one-directional aarch64->armv8a only.
  https://developer.arm.com/documentation/dui0801/b/BABBDFIH

- armv8r: Remove armv8r->armv8a (and by extension armv8r->aarch64).
  ARMv8-R is a different profile with MPU (not MMU), a different
  exception model, and profile-specific instructions.

- riscv32->riscv64: Remove. RV64 has no standard RV32 compat mode;
  identical encodings behave differently at XLEN=32 vs XLEN=64.
  https://docs.riscv.org/reference/isa/unpriv/rv64.html

- wasm32->wasm64: Remove. Separate spec targets with different address
  types (i32 vs i64); a wasm64 runtime does not accept wasm32 modules.
  https://github.com/WebAssembly/spec/blob/wasm-3.0/proposals/memory64/Overview.md
2026-04-13 19:26:18 -07:00
Jörg Thalheim
a3b13a82d4 lib/modules: short-circuit mergeDefinitions for plain singletons
The vast majority of option definitions reaching mergeDefinitions are
singletons whose value carries no _type wrapper (mkIf/mkMerge/
mkOverride/mkOrder). For those, the dischargeProperties ->
filterOverrides' -> sortProperties pipeline is a no-op yet still costs
~125k function calls and ~70k thunks on a minimal NixOS system eval.

Detect this case up front and reuse the input list as
defsFinal'.values, keeping the addErrorContext around the value probe
so error traces still point at the defining file. highestPrio is
defaultOverridePriority by construction.

A single-fold filterOverrides' was prototyped but allocates an attrset
per definition and regressed gc.totalBytes; with the fast path in
place that function is no longer hot enough to matter.

NIX_SHOW_STATS, minimal `nix-instantiate ./nixos -A system`:
  nrFunctionCalls  5490285 -> 5365172  (-125113)
  nrThunks         8182569 -> 8112150   (-70419)
  gc.totalBytes     640.0M -> 635.2M     (-4.8M)
2026-04-12 09:27:11 +02:00
nikstur
8b1ea2652a stdenv.meta: Fix erroneous CPE generation and documentation (#508061) 2026-04-11 00:44:48 +00:00
cinereal
fb3b7c0b19 lib/services: improve configure function documentation
Expand the doc comment with a structured description, type signature,
properly formatted parameter docs, and an example showing how to
implement modular services for a new containing system.
2026-04-09 09:09:47 +02:00
Samuel Dionne-Riel
ee0f02af44 lib.meta: Drop incorrect cpePatchVersionInUpdateWithVendor and cpePatchVersionInUpdateWithVendor
See the previous commits for the explanation as to why this is an invalid
value. See the follow-up commits for the complete removal of the
helpers.
2026-04-08 16:18:29 -04:00
Robert Hensing
8d4e372952 lib.types: add types.option (#499945) 2026-04-08 13:41:10 +00:00
Robert Hensing
ffe82c6a3c lib/modules: deprecate 'mkAliasIfDef' (#470154) 2026-04-07 09:05:53 +00:00
zimbatm
03b9d66f3d lib.systems.equals: use lib imports instead of builtins
Use lib.filter and lib.attrNames instead of builtins.* directly,
consistent with the rest of the file's style.

Follow-up to #506588, incorporating review feedback from #507232.
2026-04-06 18:53:16 +02:00