Commit graph

4,964 commits

Author SHA1 Message Date
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
Johannes Kirschbauer
5d7c257e33
lib/services: improve configure function documentation (#508211) 2026-04-25 21:07:57 +00: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
Robert Hensing
f303cb404b
lib/services: move portable service infrastructure out of nixos/ (#506519) 2026-04-05 19:17:30 +00:00
Philip Taron
d225695edd
lib.systems.equals: optimize removeFunctions (#506578) 2026-04-04 17:47:06 +00:00
zimbatm
878a387240 lib.systems.equals: optimize removeFunctions
Replace filterAttrs + lib.isFunction with removeAttrs + builtins.filter
+ builtins.isFunction. System attrs are never __functor-style attrsets,
so lib.isFunction's wrapper is unnecessary overhead. The double negation
(!pred ∘ !isFunction) also cancels out.

NIX_SHOW_STATS delta on hello.drvPath:

  nrFunctionCalls:  229,883 -> 154,411   (-32.8%)
  envs.number:      250,215 -> 174,743   (-30.2%)
  envs.bytes:         4.6M -> 3.4M       (-26.4%)
  nrAvoided:        291,314 -> 216,054   (-25.8%)
  gc.totalBytes:     49.7M -> 48.5M      (-2.4%)

Repro:

  NIX_SHOW_STATS=1 nix-instantiate --eval \
    -E '(import ./. {}).hello.drvPath' 2>stats.json >/dev/null
  jq . stats.json
2026-04-04 14:19:54 +02:00
cinereal
a338deb8a1
lib/services: move portable service infrastructure out of nixos/
Move the portable modular service base from
nixos/modules/system/service/portable/ to lib/services/, making it
importable by any module system (home-manager, nix-darwin) without
reaching into the nixos/ tree.

Moved files: service.nix, lib.nix, config-data.nix, config-data-item.nix,
test.nix. All external references updated (systemd/system.nix,
doc/manual/default.nix, assertions.nix, README.md).

No functional changes - only import paths differ.
2026-04-04 08:23:23 +02:00
Eman Resu
d7e6988c9b lib/strings.concatLines: call concatStringsSep directly 2026-04-03 12:54:06 -04:00
Philip Taron
d246c5c7d7
lib.sourceTypes: add obfuscatedCode (#506195) 2026-04-03 15:05:25 +00:00
Robert Hensing
17c056fa24 lib.types.optionDeclaration: test error 2026-04-03 10:53:47 +02:00
Naïm Camille Favier
6e48b2865e
convoyeur: init at 0.1.1 (#499017) 2026-04-03 05:23:21 +00:00
Ulysses Zhan
ef398065f1
lib.sourceTypes: add obfuscatedCode 2026-04-02 20:42:34 -07:00
cinereal
7334dd9096
lib.types: add types.option
Signed-off-by: cinereal <cinereal@riseup.net>
2026-04-02 12:10:29 +02:00
Robert Hensing
ff011b00be
lib/modules: Improve errors involving pushDownProperties (#502117) 2026-04-01 16:00:01 +00:00
Timothy Gallion
f32c37b88c
lib.types.defaultTypeMerge: Fix for functors with no wrapped attr
Downstream types that want to use `lib.types.defaultTypeMerge` must include
`wrapped` even though it is deprecated or the internal
`wrappedDeprecationMessage`. This is caused by accessing the
`wrapped` attr in `lib.types.defaultTypeMerge`. The logic should first check
if the attr exists and then if it does check if it is null.
2026-03-29 15:14:00 -04:00
Emily
c9fd2f4d87 lib/systems: remove redundant conditional 2026-03-29 09:07:03 +10:00
Emily
6fb3a3d12b
lib: make warnOnInstantiate recurse into overrideAttrs result (#488797) 2026-03-28 21:39:56 +00:00
ash
d6b7012245 lib: make warnOnInstantiate recurse into overrideAttrs result
This silences many `vimPlugins` warnings that are printed too eagerly
when using `nix search`.
2026-03-28 17:14:44 +00:00
Johannes Kirschbauer
075bb50b1a
lib.modules: default to emptyValue (#500104) 2026-03-25 11:00:39 +00:00
cinereal
4c7577dd94
lib.options: reflect emptyValue-based option defaults in documentation
Signed-off-by: cinereal <cinereal@riseup.net>
2026-03-24 14:02:55 +01:00
Artem Leshchev
fb932783c4 lib.licenses.bzip2: add
The identifier is not versioned, as the version there is an artifact of
an incorrect interpretation of the documentation, other variants are now
deprecated.
2026-03-23 13:14:25 -05:00