Commit graph

598 commits

Author SHA1 Message Date
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
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
nukdokplex 7abe9e95ec
lib.network: add lib.mkEUI64Suffix tests to network.sh 2025-09-09 12:23:41 +05:00
Wolfgang Walther 399136b3d7
lib/attrsets: add mapAttrsToListRecursive(Cond) function (#395160) 2025-09-08 19:12:59 +00:00
Johannes Kirschbauer b3cf9ce0f9
lib/types.either: add tests for warning in legacy case 2025-09-06 12:29:16 +02:00
Wolfgang Walther 568b19f656
maintainers: require GitHub handle
At the scale of Nixpkgs, actively maintaining a package is only possible
with integration into CI. To be able to be pinged for review requests,
the maintainer must have a GitHub handle, which:
- Leads to an invitation to the NixOS org, which comes with additional
privileges.
- Allows to request the maintainer for review as a member of this org.
- Automatically requests the maintainer for review in CI.

Currently, the GitHub handle is not strictly enforced. This leads to
some new maintainers accidentally forgetting to set these. We can avoid
these mistakes and enforce them via CI.
2025-09-02 09:57:25 +02:00
Plume 0477b30ab6
lib.attrsets.genAttrs': init (#436434)
* lib.attrsets.genAttrs': init

* lib.attrsets.genAttrs: rewrite with lib.attrsets.genAttrs'

* lib.attrsets.{genAttrs,genAttrs'}: add tests

* Update lib/attrsets.nix

Co-authored-by: Johannes Kirschbauer <hsjobeki+github@gmail.com>

* Update lib/attrsets.nix

Co-authored-by: Johannes Kirschbauer <hsjobeki+github@gmail.com>

* lib.attrsets.genAttrs': document and test attrName collision

---------

Co-authored-by: Johannes Kirschbauer <hsjobeki+github@gmail.com>
2025-09-01 11:58:28 +02:00
Mikael Voss e5ac84e29c
lib/attrsets: add mapAttrsToListRecursive(Cond) function 2025-08-31 12:11:43 +02:00
Robert Hensing 83fed2e6ff
lib.modules: init types checkAndMerge to allow adding 'valueMeta' (#391544) 2025-08-28 14:34:31 +02:00
Jörg Thalheim 1b7637ff08 nix_2_24: remove 2025-08-27 22:18:31 +02:00
Martin Weinelt 4bd0b9c7ab
Reapply "Merge remote-tracking branch 'origin/master' into staging-next"
This reverts commit 106b1418bc.

Restores the commits lost during the revert of a merge on staging-next.
2025-08-23 16:06:41 +02:00
nixpkgs-ci[bot] 6870d2a5fa
Merge master into staging-next 2025-08-17 18:05:03 +00:00
Emily 922b6476c5
lib: deprecate fromHexString on dodgy inputs (#434218) 2025-08-17 17:17:43 +01:00
nixpkgs-ci[bot] 2bdc906674
Merge master into staging-next 2025-08-16 18:05:04 +00:00
Emily 3c7d67da23 lib: deprecate fromHexString on dodgy inputs
See <https://github.com/NixOS/nixpkgs/pull/433710>.
2025-08-16 13:36:05 +01:00
Emily 677ccc5446
lib: fix overflowing fromHexString tests and example (#433710) 2025-08-16 13:25:31 +01:00
Johannes Kirschbauer 1fed6029c2
lib/tests: introduce lib cross version checks
Needed to ensure backwards stability of types.merge.v2 added in #391544
2025-08-15 15:26:32 +02:00
Martin Weinelt 106b1418bc Revert "Merge remote-tracking branch 'origin/master' into staging-next"
This reverts commit 28cafe5795, reversing
changes made to 281c9189d4.

Broken merge due to mergiraf removing many newlines from
python-packages.nix.
2025-08-15 13:58:54 +02:00
Johannes Kirschbauer 36bd116f11
lib: init lists.uniqueStrings (#355616) 2025-08-15 12:03:26 +02:00
Johannes Kirschbauer 78ac637056
lib: init lists.uniqueStrings 2025-08-15 11:45:50 +02:00
Emily 47e013c679
lib/tests/test-with-nix: run misc.nix and fetchers.nix tests in the derivation (#433729) 2025-08-14 22:24:45 +01:00
Sergei Zimmerman 609c8799fa
lib/tests/test-with-nix: run lib/tests/fetchers.nix in the derivation
This suffers from the same issue as misc.nix tests, because they
were evaluated by the host nix, not the one that is being tested.
2025-08-14 23:12:11 +03:00
Sergei Zimmerman c2698371ef
lib/tests/test-with-nix: remove broken import ./check-eval
This doesn't do the right thing here, because it evaluates
the test with nix that is evaluating the `nixpkgs-lib-tests-nix-${nix.version}`
derivation, not the Nix/Lix under test. This was just really busted for a long
time.
2025-08-14 23:12:09 +03:00
Emily 449ad44f16 lib: fix overflowing fromHexString tests and example
`fromHexString` is backed by `builtins.fromTOML`. Per [the TOML
v1.0.0 specification]:

> Arbitrary 64-bit signed integers (from −2^63 to 2^63−1) should be
> accepted and handled losslessly. If an integer cannot be represented
> losslessly, an error must be thrown.

[the TOML v1.0.0 specification]: <https://toml.io/en/v1.0.0#integer>

The saturating behaviour of the toml11 version currently used
by Nix is not lossless, and is therefore a violation of the TOML
specification. We should not be relying on it. This blocks the update
of toml11, as it became stricter about reporting this condition.

This, yes, is arguably an evaluation compatibility break. However,
integer overflow was recently explicitly defined as an error by
both Nix and Lix, as opposed to the C++ undefined behaviour it was
previously implemented as:

* <https://nix.dev/manual/nix/stable/release-notes/rl-2.25>
* <https://docs.lix.systems/manual/lix/stable/release-notes/rl-2.91.html#fixes>

This included changing `builtins.fromJSON` to explicitly
reject overflowing integer literals. I believe that the case for
`builtins.fromTOML` is comparable, and that we are effectively testing
undefined behaviour in TOML and the Nix language here, in the same way
that we would have been if we had tests relying on overflowing integer
arithmetic. I am not aware of any use of this behaviour outside of
these tests; the reverted toml11 bump in Nix did not break the 23.11
evaluation regression test, for example.

C++ undefined behaviour is not involved here, as toml11 used the C++
formatted input functions that are specified to saturate on invalid
values. But it’s still a violation of the TOML specification caused
by insufficient error checking in the old version of the library,
and inconsistent with the handling of overflowing literals in the
rest of Nix.

Let’s fix this so that Nix implementations can correctly flag up
this error and we can unblock the toml11 update.
2025-08-14 21:02:11 +01:00
Emily 6673e05ad0 lib: add fromHexString tests for distressing behaviour
This was cherry‐picked from
<https://github.com/NixOS/nixpkgs/pull/266705> and merged as part of
<https://github.com/NixOS/nixpkgs/pull/318712>, despite there being
a blocking review on the former pointing out these kinds of issues.

This documents some of the dodgy behaviour. It also can’t handle
negative literals. It might be worth considering deprecating and
dropping this, by inlining it into `lib.network.ipv6.fromString`,
its only in‐tree user.
2025-08-14 21:02:11 +01:00
Sergei Zimmerman 67ef2657ff
lib/tests/test-with-nix: run misc.nix tests in the derivation
This would have allowed us to catch to fromTOML regression in
[1] without waiting for the dogfooding on master, since previously
these tests [2] were not run for the Nix/Lix under test - only the host
nix.

[1]: https://github.com/NixOS/nix/pull/13741
[2]: https://github.com/NixOS/nixpkgs/pull/433710
2025-08-14 19:22:35 +03:00
Sergei Zimmerman 76a7b54083
lib/tests/misc: don't hardcode store directory 2025-08-14 19:18:08 +03:00
Sergei Zimmerman 74799dd97c
lib/tests/misc: don't import nixpkgs 2025-08-14 19:10:08 +03:00
Johannes Kirschbauer 45ed757e10
types/addCheck: add tests for merge v1 and v2 2025-08-13 15:09:21 +02:00
Johannes Kirschbauer cd2e5bd46c
types/merge: move 'configuration' of submodules into nested attribute set 2025-08-13 15:09:21 +02:00
Johannes Kirschbauer 1765370051
lib/modules: test revert unentional regression in check 2025-08-13 15:09:20 +02:00
Johannes Kirschbauer 9f787b30e5
lib/modules: fix test by matching error message more generically 2025-08-13 15:09:20 +02:00
Johannes Kirschbauer 8fa33000a3
lib.modules: add tests for option valueMeta 2025-08-13 15:09:20 +02:00
Wolfgang Walther fa0cba1c39
nix_2_3: drop
This has been marked insecure a while ago, as some CVEs have not been
backported. Even if *some* CVEs are fixed, we'd need **all** of them to
be, to get it back into the cache.

Not having it in the cache means, we can not test it in CI. This means
we can't make sure to actually support this version to evaluate Nixpkgs.
2025-08-12 11:28:40 +02:00
Wolfgang Walther cc3d2295b6
nixVersions.minimum: drop
The concept of this alias becomes questionable once we move past 2.18,
where Lix was forked. We should probably move to a feature-detection
based approach for lib/minver.nix eventually, too.
2025-08-12 11:28:38 +02:00
Shahar "Dawn" Or 5186921ded lib.evalModules: add graph attribute
Co-authored-by: Ali Jamadi <jamadi1377@gmail.com>
2025-08-07 11:38:16 +07:00
Robert Hensing 9dad048f21 lib.modules: Generalize the import hint to _module.args 2025-08-02 10:51:09 +02:00
Robert Hensing e28f3f0cd0 lib.modules: Test infinite recursion hint
We don't want it to occur in the trace of any unrelated errors.
2025-08-02 10:40:00 +02:00
Wolfgang Walther 5a0711127c
treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Rebecca Turner 4a81a5e556
lib.packagesFromDirectoryRecursive: Allow non-"path" directory
As initially designed, `lib.packagesFromDirectoryRecursive` allowed
passing a string for the `directory` argument. This is necessary for
several reasons:

- `outPath` on derivations and Flake inputs is not a path.
- Derivations can be coerced to their `outPath` in string interpolation,
  but that produces strings, not paths.
- `builtins.path`, bizarrely, returns a string instead of a path (not
  that the documentation makes this clear).

If a path is used instead of a string here, then Nix will dutifully copy
the entire directory into a new path in the Nix store (ignored as
WONTFIX by Eelco in https://github.com/NixOS/nix/issues/9428). For
industrial use cases, this can result in an extra 10-15 seconds on every
single eval just to copy files from one spot in the Nix store to another
spot in the Nix store.

In #361424, this was changed so that `directory` must be a path,
breaking these use-cases.

I'm not really sure what happened here -- #361424 has very little
justification for why it exists, only a reference to a previous version
of the PR (#359941), which itself had very little justification given.
The description on #359941 explained that it would "Shrink the
function's code by ~2/3rd 🎉", but 60% of the reduction in size was just
deleting comments (!) and bindings like `directoryEntryIsPackage` that
helped clarify the intent of the implementation. As a result, the new
implementation is (to my eyes) more challenging to read and understand.
I think the whole thing was in service of #392800, which adds a
`newScope` argument in order "to create nested scopes for each
(sub)directory (not just the top-level one) when `newScope` is given."

Nobody noticed this regression until after the commit was merged. After
@phanirithvij pointed out the regression, @nbraud said they would
"shortly prepare a PR to fix this" [1] but did not. Later, they would
explain that they were "quite ill the last month(s)" [2], which explains
why this got forgotten about. @nbraud also requested a review from
@Gabriella439 [3], as she had reviewed the original PR adding
`lib.packagesFromDirectoryRecursive`, but not from me, the original
author of that PR. @Gabriella439 did not review the "refactor" PR, and
no attempt to contact her or myself was made after that initial request.
This behavior is admittedly rather subtle, so I'm not sure either
Gabriella or myself would have noticed the change (especially since the
relevant PR restructures the entire implementation).

While I find this a bit frustrating, I should have added a test for this
use-case in my original PR; if there was a test that relied on passing
paths in as a string, perhaps the authors modifying this code would have
noticed that the implementation was not an accident.

[1]: https://github.com/NixOS/nixpkgs/pull/361424#discussion_r1912407693
[2]: https://github.com/NixOS/nixpkgs/pull/359984#issuecomment-2775768808
[3]: https://github.com/NixOS/nixpkgs/pull/361424#issuecomment-2521308983
2025-07-10 16:13:38 -07:00
Johannes Kirschbauer 86603255c3
lib.filesystem.resolveDefaultNix: init (#418824) 2025-07-03 12:54:47 +02:00
Alyssa Ross a61841a597 nixVersions.nix_2_3: add knownVulnerabilities 2025-06-30 10:26:29 +02:00