Commit Graph

553 Commits

Author SHA1 Message Date
Wolfgang Walther
2f2221f44c 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.

(cherry picked from commit 568b19f656)
2025-09-02 08:10:32 +00:00
Jörg Thalheim
0beac304d7 ci: replace nix_2_24 with nix_2_28
This is a partial backport of the nix_2_24 removal PR, containing
only the CI testing changes that update the tested nix versions.

(cherry picked from commit 1b7637ff08)
2025-08-29 15:56:45 +02:00
Sergei Zimmerman
d5edba18e8 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.

(cherry picked from commit 609c8799fa)
2025-08-18 16:43:17 +00:00
Sergei Zimmerman
da5d00ad9c 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.

(cherry picked from commit c2698371ef)
2025-08-18 16:43:17 +00:00
Sergei Zimmerman
16a05de638 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

(cherry picked from commit 67ef2657ff)
2025-08-18 16:43:17 +00:00
Sergei Zimmerman
0e04293d59 lib/tests/misc: don't hardcode store directory
(cherry picked from commit 76a7b54083)
2025-08-18 16:43:17 +00:00
Sergei Zimmerman
e888a09931 lib/tests/misc: don't import nixpkgs
(cherry picked from commit 74799dd97c)
2025-08-18 16:43:16 +00:00
Emily
fce01f7d71 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.

(cherry picked from commit 449ad44f16)
2025-08-16 12:26:14 +00:00
Emily
b591001250 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.

(cherry picked from commit 6673e05ad0)
2025-08-16 12:26:13 +00:00
Wolfgang Walther
c6efa35204 lib/tests: don't test with Nix 2.3 anymore
The `nixVersions.minimum` alias has been removed on unstable, so the
TODO is not needed anymore.

The lib tests can't be run with Nix 2.3 anymore, because this version is
not available on unstable anymore - and thus also not in the pinned
nixpkgs that CI is run with.

(cherry picked from commit cc3d2295b6)
2025-08-12 19:22:29 +02:00
Wolfgang Walther
aefcb0d50d treewide: run nixfmt 1.0.0 2025-07-24 14:58:18 +02:00
Gutyina Gergő
feb1a72ead lib/strings: init replaceString
(cherry picked from commit b5720e2b3f)
2025-07-09 16:41:16 +00:00
Alyssa Ross
b5ba0055ef nixVersions.nix_2_3: add knownVulnerabilities
(cherry picked from commit a61841a597)
2025-06-30 10:39:18 +02:00
sodiboo
7c871446f4 lib.types.attrTag: expose suboptions at correct level
(cherry picked from commit b3c9916455)
2025-06-23 06:44:11 +00:00
Jade Lovelace
baf024b092 ci/eval: accept nix directly
Previously we were taking nixVersions and this made external use from
the Lix repo's CI annoying.

We should probably also test other nix versions than stable (i.e. also
latest and Lix), but this involves writing GitHub Actions about it and
maybe not running it on every single PR. Future work.

(cherry picked from commit 332bc64369)
2025-06-10 23:33:09 +00:00
Wolfgang Walther
af25d1ce8c lib/tests: avoid full rebuild when only maintainers change
The vast majority of CI jobs to build the lib tests are caused by
changes in the maintainer list. In this case, we currently run the full
test-suite which takes 3-4 minutes. By moving the maintainers and teams
tests out of the test-with-nix file, we save almost all of that.
Building only those two tests on a change is almost instant. This only
works, because we previously enabled cachix for the workflow.

Note, that these tests are not actually run with both nix versions, even
though they were listed in the "test with specific nix version" file.
That's because we only differ in the nix version run *inside* the
sandbox, but not doing the outer build.

Since this file seems to be re-used by NixOS/nix' CI, this is
technically a small loss in coverage for that repo, but nixpkgs CI
considerations outweigh that. But because of this, I left the other
non-nix-version-specific tests in that file.

(cherry picked from commit a7f4e0f9ae)
2025-06-02 07:31:00 +00:00
Wolfgang Walther
c8d2eca963 .editorconfig: move subfolder config into separate .editorconfig files
This avoids paths in the top-level file getting out-of-sync, because the
.editorconfig files would be moved together with the files they target.
2025-05-07 20:01:35 +02:00
Johannes Kirschbauer
be393db73e lib.takeEnd: init (#398222) 2025-04-23 14:20:47 +02:00
Pol Dellaiera
a9320986b3 lib.strings: init splitStringBy (#385643) 2025-04-23 04:51:38 +00:00
Norbert Melzer
b2f1b6b8f0 lib/strings: Zero‐pad hex digits in escapeC (#399722) 2025-04-21 17:12:55 +02:00
Johannes Kirschbauer
843af863e6 lib.options.mkPackageOption: use lib.showAttrPath (#398066) 2025-04-21 10:51:01 +02:00
Johannes Kirschbauer
013beed1db lib/types: check paths in pathWith with hasStorePathPrefix (#387304) 2025-04-21 10:45:23 +02:00
Mikael Voss
487a002c63 lib/strings: Zero‐pad hex digits in escapeC
lib.strings.escapeC produces single‐digit hexadecimal strings for
character values ≤ 15, which results in an ambiguity. If the following
character is a hex digit, it will be interpreted as being part of the
escape sequence.

systemd, which also relies on C‐style escape sequences, does not
decode single‐digit sequences at all, even if unambiguous.

Padding the hexadecimal string with "0" avoids this problem.
2025-04-18 13:41:53 +02:00
Matt Sturgeon
6107d48bcb lib.options.mkPackageOption: use lib.showAttrPath
Make use of `lib.showAttrPath` instead of manually doing `concatStringsSep "."`.

This means edge-cases such as the attr-path including names that are not
valid nix identifiers will be handled better.

See:
- https://nix.dev/manual/nix/2.26/language/identifiers
- https://nixos.org/manual/nixpkgs/unstable/#function-library-lib.attrsets.showAttrPath
2025-04-13 20:54:13 +01:00
Matt Sturgeon
4c26f96059 lib/tests/modules: test all mkPackageOption cases
There were several test case options declared in `declare-mkPackageOption.nix`
that were not actually tested in `modules.sh`.
2025-04-13 20:54:12 +01:00
azahi
9fee9e7371 lib.takeEnd: init 2025-04-13 17:37:35 +03:00
K900
aece6a0c1f Merge remote-tracking branch 'origin/master' into staging-next 2025-04-11 21:17:42 +03:00
Robert Hensing
3e5af839c2 lib.types.submodule: Disable check during docs generation (#396907) 2025-04-11 19:12:32 +02:00
nixpkgs-ci[bot]
c55a1a7779 Merge master into staging-next 2025-04-11 00:15:47 +00:00
Robert Hensing
e09cf9f066 lib.types.submodule: Disable check during docs generation
Put simply docs generation is a weird eval, and we should avoid
generating any unnecessary errors.
2025-04-11 00:32:01 +02:00
Robert Hensing
d84b0024f6 lib/modules: export class inside specialArgs (#395141) 2025-04-10 20:58:41 +02:00
Michael Hoang
6de9039315 lib/modules: add class to specialArgs
Co-Authored-By: Johannes Kirschbauer <hsjobeki@gmail.com>
2025-04-10 17:58:40 +02:00
nixpkgs-ci[bot]
6c98e107c7 Merge master into staging-next 2025-04-09 00:15:45 +00:00
Jörg Thalheim
abd52dd872 nixVersions.{nix_2_28,nix_2_26}: switch simplified meson build
So we are adding a simplified version that builds a monolithic nix binary to get finished
in time for the release. Afterwards we will switch to the modular build again.
2025-04-08 12:29:11 -04:00
Heitor Augusto
bb4be9a474 lib.strings: init splitStringBy 2025-04-07 15:51:18 -03:00
K900
b3146d4446 Merge remote-tracking branch 'origin/master' into staging-next 2025-04-07 21:21:10 +03:00
Johannes Kirschbauer
33daa3f4b9 lib.modules: init test for lib.mkDefinition 2025-04-03 15:03:00 +02:00
Emily
1e6ab3434f treewide: drop support for 32‐bit Darwin
It’s dead, Jim.
2025-04-02 21:20:44 +01:00
Mikael Voss
931f464581 lib/types: check paths in pathWith with hasStorePathPrefix
This permits usage of content‐addressed derivations and has the added
benefit of checking normalised paths.
2025-04-02 13:28:52 +02:00
Silvan Mosberger
374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Robert Hensing
bb984408d5 lib/tests/release.nix: Use nix.overrideScope for >=2.26 2025-03-31 00:47:37 +02:00
Robert Hensing
90c1822309 nixVersions.nix_2_26: Fix cross and static 2025-03-26 18:33:43 -04:00
nicoo
32235deeb8 lib.packagesFromDirectoryRecursive: default to creating new scopes when newScope is provided
Co-authored-by: Rebecca Turner <rbt@sent.as>
2025-03-26 12:11:44 +01:00
nicoo
41f219d1d9 lib.packagesFromDirectoryRecursive: add tests for nested scopes 2025-03-26 12:11:43 +01:00
nicoo
fdd2c6f80f lib/tests: move packages-from-directory/* into a subdir
in preparation for adding more tests for `lib.packagesFromDirectoryRecursive`
2025-03-24 18:35:26 +01:00
Johannes Kirschbauer
484a0477d8 lib/types: types.either deprecate functor.wrapped in favor of functor.payload.elemType 2025-03-20 14:11:34 +00:00
Johannes Kirschbauer
4f123107b4 lib/types: types.coercedTo deprecate functor.wrapped in favor of functor.payload.elemType 2025-03-15 00:46:02 +09:00
Johannes Kirschbauer
f6214eb786 lib/types: types.functionTo deprecate functor.wrapped in favor of functor.payload.elemType 2025-03-15 00:45:39 +09:00
Johannes Kirschbauer
4fe25460e1 lib/types: types.nullOr deprecate functor.wrapped in favor of functor.payload.elemType 2025-03-15 00:45:30 +09:00
Johannes Kirschbauer
05958f27e2 lib/types: types.{unique,uniq} deprecate functor.wrapped in favor of functor.payload.elemType 2025-03-15 00:05:55 +09:00