Commit graph

641 commits

Author SHA1 Message Date
John Ericson
704e1a5c16
lib.systems: add uefi support (#477645) 2026-03-02 05:32:37 +00:00
Silvan Mosberger
b54233e11c lib.maintainers: Enforce unique github[Id], email, matrix 2026-02-09 21:51:01 +01:00
Silvan Mosberger
58b187378d
lib/modules: add suggestions to invalid option name errors (#442263) 2026-02-03 19:10:35 +00:00
Theo Paris
9f605ca95e
lib.systems: add uefi support
Signed-off-by: Theo Paris <theo@theoparis.com>
Change-Id: I51ce15449fc83f0ff39277d7cde7b34a6a6a6964

lib.systems: remove i686-uefi
2026-01-25 21:59:21 -08:00
Dyego Aurélio
28096cc5e3 treewide: apply nixfmt 1.2.0 2026-01-22 18:37:56 -03:00
Johannes Kirschbauer
04c56b7e59
lib.lists.replaceElemAt: init (#477775) 2026-01-22 15:58:28 +00:00
Johannes Kirschbauer
f4d45cdced
lib/types: add tests for types.mkStructuredType 2026-01-20 21:26:05 +01:00
Johannes Kirschbauer
53b47eb93d
lib/tests: add strict option to checkConfigOutput 2026-01-20 21:26:05 +01:00
Glen Huang
0445cc8aab lib.lists.replaceElemAt: init
It's very easy to resort to lib.take + lib.drop to accomplish this, but it's not obvious that it actually performs quite badly.

Replacing an item in a list should be a relative common operation.
2026-01-12 11:58:42 +00:00
Shelvacu
5018a33b62 lib/strings.escapeNixIdentifier: quote keywords
Previously `lib.strings.escapeNixIdentifier "assert"` would return `"assert"`; This is wrong, `assert` is not a valid identifier unless quoted.\

This also fixes `lib.generators.toPretty`: `toPretty {} { "assert" = false; }` would previously return an invalid expression.
2026-01-02 13:47:32 -08:00
Robert Hensing
34b2f6702f
lib.makeOverridable: preserve constructor override and metadata attributes (#461032) 2025-12-22 13:20:41 +00:00
Tom Hubrecht
ba6b3a4f6c
lib/tests: Use --option to enable abort-on-warn 2025-12-08 08:44:53 +01:00
Robert Hensing
649a766e35 lib/tests: move throwTestFailures tests to standalone script
The throwTestFailures tests in misc.nix produce confusing trace output
that looks like test failures even when tests pass.

This commit moves these tests to a new lib/tests/debug.sh script,
following the pattern from modules.sh, sources.sh, and filesystem.sh.

The confusing trace output does not appear in any logs anymore.

Example of the confusing log:

trace: FAIL "testDerivation":
Expected:
<derivation a>

Result:
<derivation b>

evaluation warning: Using `lib.generators.toPlist` without `escape = true` is deprecated
[ ]
2025-11-26 23:51:59 +01:00
Robert Hensing
75c025c613
lib/types: make attrTag's description field list valid choices (#464627) 2025-11-25 18:28:32 +00:00
Johannes Kirschbauer
3ae8192162
lib: deprecate fold (#456532) 2025-11-25 14:15:41 +00:00
cinereal
cf4da9fd69
lib/types: make attrTag's description field list valid choices
Lists the valid choices in `attrTag` type's `description` field.
Given this description is used in error messages, this serves to make
for somewhat more descriptive errors in the event an option involving
this type turns out not to match.

Signed-off-by: cinereal <cinereal@riseup.net>
2025-11-24 18:45:48 +01:00
Yueh-Shun Li
21021adbe9 lib.makeOverrdable: preserve constructor override and metadata attributes 2025-11-13 18:01:44 +08:00
Rebecca Turner
dc4cf16993 lib.debug.throwTestFailures: init
`lib.debug.runTests` provides a unit test evaluator for Nix, but its
results are returned in a raw and difficult-to-read form.

Currently, different callers output the results in various ways:
`builtins.throw (builtins.toJSON failures)` and `builtins.throw ("Tests
failed: " + lib.generators.toPretty { } failures)` are both used.

This change adds a new `lib.debug.throwTestFailures` function which
displays the results nicely before throwing an exception (or returns
`null` if no failures are given), unifying these disparate call-sites.

First, each failing test is pretty-printed in a `trace` message:

```
trace: FAIL testDerivation:
  Expected: <derivation a>
    Result: <derivation b>
```

Then, an exception is thrown containing the number of tests that failed
(and their names), followed by the raw JSON of the results (for parity
with previous usage, and because `lib.generators.toPretty` sometimes
omits information that `builins.toJSON` includes):

```
error:
       … while evaluating the file '...':

       … caused by explicit throw
         at /nix/store/.../lib/debug.nix:528:7:
          527|       in
          528|       throw (
             |       ^
          529|         builtins.seq traceFailures (

       error: 1 tests failed:
       - testDerivation

       [{"expected":"/nix/store/xh7kyqp69mxkwspmi81a94m9xx74r8dr-a","name":"testDerivation","result":"/nix/store/503l84nir4zw57d1shfhai25bxxn16c6-b"}]
```
2025-11-10 10:41:31 -08:00
Felix Buehler
3106949fd7 lib/types: add externalPath 2025-11-04 22:57:16 +01:00
Robert Hensing
49f0cbd7f8
lib.types: introduce a fileset type (#428293) 2025-11-04 13:44:33 +00:00
Robert Hensing
acb6191c6e
lib: Add splicing utilities (#426889) 2025-10-30 21:22:54 +00:00
Aliaksandr
f4d36941eb
lib: deprecate fold 2025-10-30 16:56:49 +02:00
Robert Hensing
586961172a
lib/modules: Report error for unsupported t // { check = ...; } (#454964) 2025-10-28 16:40:39 +00:00
Robert Hensing
143ca6688b lib/modules: Fix suggestions in submodules 2025-10-28 15:22:17 +01:00
Robert Hensing
cdefdba743 lib/modules: Support multiple suggestions, optimize 2025-10-28 15:17:08 +01:00
Silvan Mosberger
7636389851 lib.teams: Add githubId from associated github teams
This will allow the code for https://github.com/NixOS/nixpkgs/issues/447514
to make sure that the right team is requested for review,
even if it has been renamed in the meantime.

While the matching is currently based on the teams slug/name and not the
id, renames won't cause problems with `lib.teams`, because CI would
error if there's no match. Changing this can be future work.
2025-10-28 00:01:51 +01:00
Silvan Mosberger
ddf8b5da4a lib.teams: Add githubMaintainers field
This is so you can figure out who to ask to get added to the team

Also avoid an unecessary `{ inherit lib; }` argument
2025-10-27 19:36:58 +01:00
Aliaksandr
dc7095a86e
treewide: remove deprecated lib functions that had warning for more than 2 years 2025-10-24 06:30:16 +03:00
Robert Hensing
93ea59f66d lib/modules: Report error for unsupported // { check }
`check` can have a new place since the introduction of
merge.v2. This makes the // { check = ... } idiom unreliable.

In this PR we add checks to detect and report this.

merge.v2 introduced in:
https://github.com/NixOS/nixpkgs/pull/391544

Real world case:
https://hercules-ci.com/github/hercules-ci/hercules-ci-effects/jobs/875
2025-10-23 19:06:05 +02:00
Lukas Wurzinger
73e8a483e6
lib/cli: add toCommandLine 2025-10-21 21:01:32 +02:00
Silvan Mosberger
1ea51e1f1a lib.teams: Remove .githubTeams in favor of singular .github
No team was using the feature of having multiple GitHub teams, and this
would make it tricky to try to sync maintainer teams with GitHub teams.
2025-10-08 21:44:39 +02:00
Wolfgang Walther
91a8fee3aa
treewide: remove redundant parentheses
Auto-fixed by nixf-diagnose.
2025-10-05 10:52:03 +02:00
Robert Hensing
6a5f6f1a4e
lib: init strings.join (#446278) 2025-10-02 15:34:34 +00:00
Philip Taron
44998896c6
lib: remove optional builtins prefixes from prelude functions (#447402) 2025-09-30 16:28:04 +00:00
John Ericson
941a243895
cygwin: add as a cross-compilation target, and get hello to build (#444470) 2025-09-30 14:16:25 +00:00
NAHO
e8f998c3bc
lib: add builtins prefixes for prelude functions to improve clarity 2025-09-30 09:38:12 +02:00
NAHO
6177c4ad72
lib: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd --type file . lib --exec-batch sed --in-place --regexp-extended "
      s/\<builtins\.($(
        printf '%s\n' "${builtins[@]}" |
          paste --delimiter '|' --serial -
      ))\>/\1/g
    "

    nix fmt
2025-09-30 09:02:59 +02:00
David McFarland
39fd8e4adf cygwin: init as a target toolchain
The old cygwin support used -pc-windows-cygnus as the config.  This is
supported by LLVM, but not by GNU. This will change it to -pc-cygwin,
which is more generally supported.

Because the kernel is now 'cygwin' rather than 'windows', isWindows will
return false. There are lots of different reasons isWindows is used in
nixpkgs, but in my experience they often have to do with posix
compatibility and don't apply to cygwin.

Co-authored-by: Brian McKenna <brian@brianmckenna.org>
2025-09-27 13:29:44 -03:00
Johannes Kirschbauer
b37ac6a920
lib: init strings.join 2025-09-27 09:18:37 +02:00
Johannes Kirschbauer
2b2df96038
lib/types: submodule fix description with freeformType (#443134) 2025-09-25 14:57:10 +00:00
Robert Hensing
35cb0d92d8 lib/tests/modules: Test description composition 2025-09-17 14:00:10 +02:00
Johannes Kirschbauer
348e5028e7
lib/types: minimal fix for the regression of either when used in freeformType (#440459) 2025-09-14 04:38:10 +00:00
Winter
0f54833b4a lib/modules: add suggestions to invalid option name errors
This change introduces the suggesting of possible valid option names for
a given invalid option, based on the keys of said invalid option's
parent attrset. That is, `foo.bar.baz` will only be suggested keys from
`foo.bar`, while `(config).baz` will only be suggested keys from the
toplevel.
2025-09-11 23:12:45 -04:00
Robert Hensing
0bdb5c1be2
lib.options.optionAttrSetToDocList: add visible = "transparent" (#441782) 2025-09-11 18:24:13 +00:00
Matt Sturgeon
6c20442479
lib.options.optionAttrSetToDocList: add visible = "transparent"
Allows marking an option as invisible, without excluding its sub-options.

In practice, this is similar to `visible = true; internal = true;`,
however it is more explicit and less reliant on implementation details.
2025-09-11 17:00:17 +01:00
misuzu
8d45e68ff1
lib.mkEUI64Suffix: init (#416086) 2025-09-11 15:26:02 +00:00
nukdokplex
d24f103572
lib.mkEUI64Suffix: fix syntax errors and tests 2025-09-11 00:01:53 +05:00
nukdokplex
68253aae9b
lib.mkEUI64Suffix: bring @hsjobeki suggestions
renamed `mac` to `octets` in hextets combining step for better var
naming; rephrased error message to provide a hint of expected format;
replaced `Arguments` with `Inputs` in docstring; added more test cases
for invalid hex digits; added comments in hextets combining step;
2025-09-10 23:41:18 +05:00
Matt Sturgeon
1efdbe8f2f
lib/tests/misc: add option visibility test 2025-09-10 14:34:59 +01:00
Marie Ramlow
b6d48619ed lib.systems: add ppc32 target 2025-09-10 08:15:07 +02:00