Commit graph

616 commits

Author SHA1 Message Date
Robert Hensing acb6191c6e
lib: Add splicing utilities (#426889) 2025-10-30 21:22:54 +00:00
Robert Hensing 586961172a
lib/modules: Report error for unsupported t // { check = ...; } (#454964) 2025-10-28 16:40:39 +00: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
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
Robert Hensing 7ba464154f lib: Introduce Cross Index concept
A Cross Index, short for Cross Platform Pair Index, is the essential
shape of a splice, without the invoking the more mind bending concept
of adding variations of for these 6 pairings to an existing thing so
that it can be switched out for something else.

So the purpose of a Cross Index is to contain the result of `f`\
(which may be reified in code, or just an abstract concept):
 - f "build" "build"
 - f "build" "host"
 - ...

Splicing on the other hand refers not just to these six variants, but
to the idea of tacking them onto one of the variants. (hostTarget,
I believe)

Cross Indexes are a necessity for making cross compilation work, but
splicing is more than necessary.
2025-09-09 04:42:37 +02:00
Robert Hensing ca4beaaf1c lib: Add splice structure utilities 2025-09-09 04:42:36 +02: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