Commit graph

4488 commits

Author SHA1 Message Date
Yueh-Shun Li 3930eee7b0 lib.extendMkDerivation: document the typical usage of inheritFunctionArgs
(cherry picked from commit d75b203514)
2025-11-07 00:56:30 +08:00
Yueh-Shun Li edbac72fad lib.extendMkDerivation: fix argument documentation layout
(cherry picked from commit 7f6ce9097f)
2025-11-07 00:56:29 +08:00
Yueh-Shun Li d4f704a8f4 lib.extendMkDerivation: adjust default value documentation
(cherry picked from commit 918e017d64)
2025-11-07 00:56:29 +08:00
Silvan Mosberger 1d47e0e792 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.

(cherry picked from commit 7636389851)
2025-10-28 17:04:26 +01:00
Silvan Mosberger 2e0cd80b35 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

(cherry picked from commit ddf8b5da4a)
2025-10-28 17:04:26 +01:00
Silvan Mosberger 2a57eba108 lib.teams: Populate fields from synced GitHub state
The before and after of

    nix-instantiate --eval -A lib.teams --strict --json | jq 'walk(if type == "array" then sort else . end)'

has been ensured to be negligible, only consisting of minor team
shortName and scope differences

(cherry picked from commit 428bd8f1a2)
2025-10-28 17:04:25 +01:00
Silvan Mosberger 6572669720 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.

(cherry picked from commit 1ea51e1f1a)
2025-10-28 17:03:14 +01:00
Wolfgang Walther 5cbdb94f3a
treewide: remove redundant parentheses
Auto-fixed by nixf-diagnose.

(cherry picked from commit 91a8fee3aa)
2025-10-05 12:59:25 +02:00
Plume 678ff5cf1c 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>
(cherry picked from commit 0477b30ab6)
2025-09-07 12:46:11 +00:00
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ő 977242de6d lib: prefer replaceString over replaceStrings
(cherry picked from commit b3b0fd266b)
2025-07-09 16:41:16 +00: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
Emily ea235dc9ee Revert "lib.meta.availableOn: Return false if pkg parameter is null"
I believe this change is wrong both theoretically and practically.

Theoretically, `null` is available on every platform, because
`buildInputs = [ null ];` always succeeds and never throws a platform
availability error. `null` should be handled consistently with packages
that have no explicit list of supported platforms, as it of course
has no such list itself.

Practically, we use `null` to represent libraries that are always
present on a platform and do not require a library (for instance,
because they are part of `libc` or the macOS SDK). This has been
used for a long time by `libintl` (on all non‐glibc platforms),
and is also now used by `libGL` and friends on Darwin. This change
broke the check SDL3 does for OpenGL availability on Darwin, causing
<https://github.com/NixOS/nixpkgs/issues/407056>, which had to be
worked around by <https://github.com/NixOS/nixpkgs/pull/409525>.

Both `libintl` and `libGL` should count as available on platforms
where their functionality is part of the standard build environment,
and a package that is completely unavailable and whose functionality
cannot be expected should not use `null`, as it should result in
errors if used in a dependency list on an unsupported platform.

I accept that overriding with `null` is often a useful way to disable
dependencies that don’t have explicit feature flags, but I do not
think that making it work better with feature flags conditioned on
availability is worth the inconsistency and problems caused by this
change. Packages can instead expose the relevant feature flags as
arguments that default to the `lib.meta.availableOn` check or, if they
want to keep an “override the dependency to `null`” interface,
insert an explicit `pkg != null && …` check.

Additionally, the pull request was merged over a week after all
breaking changes were restricted for the 25.05 release. I believe that
the potential problems of dealing with the effects of this change for
an entire release cycle – the first release cycle where `libGL` is
`null` on Darwin, a change I made before the deadline and before this
change to `lib.meta.availableOn` – offset the risks of backporting
this revert at such a late stage.

It will cause overrides to backwards‐incompatibly revert to the
behaviour they had before the change, but since such overrides were
not possible until a few weeks ago, I hope that is an acceptable risk
compared to the potential issues leaving this in the release can
cause, given that it was merged after the deadline and has already
broken an existing construction in Nixpkgs.

This reverts commit 9338d924db.

(cherry picked from commit 98dbc7cc58)
2025-05-23 17:39:28 +00:00
Arian van Putten 871526be1f
nixos/image/repart: Use own assertions / warnings. (#406940) 2025-05-15 19:14:53 +02:00
Aleksana 40a774220d
ipxe: correct licensing information (#390934) 2025-05-15 21:42:59 +08:00
Alyssa Ross 7eb2580981 lib.systems.examples.riscv64-musl: init 2025-05-15 14:44:58 +02:00
Morgan Jones 865c1cb0e9
lib/systems: remove android cruft (#406682) 2025-05-14 17:46:48 -07:00
Will Fancher 4b0d1225f5 lib/asserts: Factor out NixOS's toplevel assertion / warning logic. 2025-05-14 01:21:10 -04:00
Fernando Rodrigues 8d21ee745e
licenses: add gpl2UBDLPlus
Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net>
2025-05-13 16:49:21 +00:00
Morgan Jones 9d3c069cbd
lib/systems: remove android cruft
These used legacy names for Android SDK and NDK versions, so now we can
do away with them.
2025-05-12 23:43:16 -07:00
Jeremy Fleischman 63c815dd79
docs: fix typo: readDir -> dirOf
The example code here uses `dirOf`, not `readDir`. I assume this was
just a silly typo.
2025-05-12 00:36:30 -07:00
Matt Sturgeon 1fb1446380
lib.modules.importApply: Fix doc typo; _keykey
The `importApply` docs reference using the `_key` attr along with
`importApply` or `_file`, however the actual attr name used by the
module system is `key`.
2025-05-08 17:48:50 +01:00
Johannes Kirschbauer 5ee93d2532
lib: refactor lib.attrsets.{mapAttrs', mapAttrsToList} and mapAttrs'' in the strongswan-swanctl module (#403581) 2025-05-08 09:42:40 +02:00
ccicnce113424 4551258940 lib: refactor lib.attrsets.{mapAttrs', mapAttrsToList} and mapAttrs'' in the strongswan-swanctl module
The new implementation of `mapAttrsToList` is simpler than the previous one, avoiding an extra string conversion. Benchmarking shows a slight performance improvement. See the discussion here: https://discourse.nixos.org/t/another-implementation-of-mapattrstolist

Additionally, I searched nixpkgs for expressions equivalent to the old `mapAttrsToList` and replaced them with direct calls to the new implementation.
2025-05-08 13:58:54 +08: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
Vladimír Čunát 7aeb16e7ff
Merge master into staging-next 2025-05-04 08:07:53 +02:00
Jörg Thalheim 211568d4fd
lib.systems: add golang platform dialect (#403030) 2025-05-04 06:04:53 +02:00
nixpkgs-ci[bot] 7be7cc17c3
Merge master into staging-next 2025-05-02 18:05:12 +00:00
adisbladis 9338d924db lib.meta.availableOn: Return false if pkg parameter is null
To fix overriding packages that checks for platform compatibility, like pipewire.

`pipewire` contains the following logic to enable support for ldac depending on library platform compatibility:
```nix
ldacbtSupport = lib.meta.availableOn stdenv.hostPlatform ldacbt
```

Which is used later in the expression to create a Meson flag:
```nix
(lib.mesonEnable "bluez5-codec-ldac" (bluezSupport && ldacbtSupport))
```

This means that attempting to build `pipewire` without `ldacbt` like:
```nix
pipewire.override {
  ldacbt = null;
}
```
will fail because the the Meson flag indicates the feature should be enabled, but the library is passed to `buildInputs` as `null`.
2025-05-02 19:01:17 +02:00
aleksana e1828f9668 lib.systems: add golang platform dialect 2025-04-30 22:05:32 +08:00
K900 19e54b8a69 Merge remote-tracking branch 'origin/master' into staging-next 2025-04-30 07:14:48 +03:00
aleksana 06bb544356 lib.systems.inspect.patterns.isEfi: add loongarch 2025-04-29 22:50:31 +08:00
nixpkgs-ci[bot] c376a565f9
Merge staging-next into staging 2025-04-24 18:04:57 +00:00
jopejoe1 13c1207a12
font-{alias,util}, gccmakedep, libp{ciacces,threadstub}s: refactor and migrate to pkgs/by-name from xorg namespace (#369520) 2025-04-24 19:11:58 +02:00
zowoq 0931f4e861 Revert "pkgs/top-level/stage.nix: add pkgsLLVMLibc"
This reverts commit 41b14024d2.
2025-04-24 14:04:25 +10:00
Johannes Kirschbauer be393db73e
lib.takeEnd: init (#398222) 2025-04-23 14:20:47 +02:00