Commit Graph

479 Commits

Author SHA1 Message Date
Silvan Mosberger
2936a2ab9b
lib.strings.concatMapAttrsStringSep: init (#330010) 2024-12-06 09:53:50 +01:00
Yueh-Shun Li
b1371135b5 lib.strings.concatMapAttrsStringSep: init 2024-12-06 11:02:26 +08:00
Johannes Kirschbauer
ce8f304bb6
lib.types.attrsWith: remove failing test 2024-12-03 10:04:27 +01:00
Silvan Mosberger
e60e2e6916
lib/types: standardise attrsOf functor.wrapped warning and add a test 2024-12-03 10:03:13 +01:00
Silvan Mosberger
bd353d322c
lib/types: Test attrsWith type merging
Co-Authored-By: @hsjobeki
2024-12-03 10:02:47 +01:00
Johannes Kirschbauer
5b7a21358d
lib/types: init {types.attrsWith} 2024-12-03 10:02:40 +01:00
K900
907cb3d253
Revert "lib/types: init {types.attrsWith}" 2024-12-03 09:06:24 +03:00
Silvan Mosberger
23a7a7d8b4
lib/types: init {types.attrsWith} (#354738) 2024-12-02 16:47:32 +01:00
Silvan Mosberger
d5eccbbbae lib/types: standardise attrsOf functor.wrapped warning and add a test 2024-12-02 16:18:03 +01:00
Philip Taron
9396352fba
lib/systems: elaborate properly with non-matching system / config / parsed args (#351608) 2024-11-29 15:48:15 -08:00
John Ericson
07f8638828
freebsd: Add support for aarch64 (#358053) 2024-11-26 20:39:38 -05:00
Silvan Mosberger
415d1932ea lib/types: Test attrsWith type merging
Co-Authored-By: @hsjobeki
2024-11-25 16:06:55 +01:00
Johannes Kirschbauer
c4a9529071
lib/types: init {types.attrsWith} 2024-11-25 15:11:45 +01:00
Silvan Mosberger
b234fd831a
lib.types.defaultTypeMerge: refactor functor.{payload,wrapped} merging (#350906) 2024-11-24 11:44:56 +01:00
Artemis Tosini
2b02a18ef7
freebsd: Add support for aarch64
Add a new `aarch64-freebsd` double and example system,
then fix include and libc to work.
This is enough to build packages like `hello`,
either static or dynamic.

This is useful for testing nix FreeBSD on a Raspberry Pi.
2024-11-24 03:03:28 +00:00
Silvan Mosberger
fbbe972898 Parallel GH actions workflow for Nixpkgs eval
Motivated by ofborg struggling [1] and its evaluations taking too long,
inspired by Jörg's initial PR [2]
and Adam's previous attempt to parallelise Nixpkgs evaluation [3],
this PR contains initial work to relief ofborg from its evaluation duty
by using GitHub Actions to evaluate Nixpkgs.

For now this doesn't take care of all of what ofborg does, such as
requesting appropriate reviewers or labeling mass rebuilds, but this can
be follow-up work.

[1]: https://discourse.nixos.org/t/infrastructure-announcement-the-future-of-ofborg-your-help-needed/56025?u=infinisil
[2]: https://github.com/NixOS/nixpkgs/pull/352808
[3]: https://github.com/NixOS/nixpkgs/pull/269403

Co-Authored-By: Jörg Thalheim <joerg@thalheim.io>
Co-Authored-By: Adam Joseph <adam@westernsemico.com>
2024-11-20 10:35:56 +01:00
Johannes Kirschbauer
b978799f71
lib.types.defaultTypeMerge: refactor functor.{payload,wrapped} merging 2024-11-19 08:58:38 +01:00
seth
205faabfeb
lib.systems.doubles: add aarch64-windows double 2024-11-06 17:22:52 -05:00
Wolfgang Walther
3c21a5c9d6
lib/systems: elaborate properly with non-matching system / config / parsed args
When elaborating a system with both "config" and "system" arguments
given, they might not match the parsed results.  Example:

elaborate {
  config = "i686-unknown-linux-gnu";
  system = "x86_64-linux";
}

This would result in a parsed system for i686, because the config
argument is preferred.  But since "// args //" comes after system has
been inferred from parsed, it is overwritten again.  This results in
config and parsed all pointing to i686, while system still tells the
story of x86_64.

Inconsistent arguments can also be given when passing "parsed" directly.
This happened in stage.nix for the various package sets.

The solution is simple: One of the three arguments needs to be treated
as the ultimate source of truth.  "system" can already be losslessly
extracted from "parsed".  However, "config" currently can not, for
example for various -mingw32 cases.  Thus everything must be derived
from "config".

To do so, "system" and "parsed" arguments are made non-overrideable for
systems.elaborate.  This means, that "system" will be used to parse when
"config" is not given - and "parsed" will be ignored entirely.

The systemToAttrs helper is exposed on lib.systems, because it's useful
to deal with top-level localSystem / crossSystem arguments elsewhere.
2024-11-03 17:38:19 +01:00
Silvan Mosberger
5690833b4f
lib: improve filterAttrs (#345547) 2024-11-01 11:54:20 +01:00
h7x4
83e1488c6d
lib/tests: test filterAttrs 2024-10-25 15:08:15 +02:00
Felix Stupp
f35a61d8a6
lib.modules: fix test line using empty "$@"
Probably a missed left over from somewhere in
the commit 58f385f680.
As can be seen in that commit where this line was introduced,
"$@" was also just emptied by the last `set` call in line 169.
This line is currently valid, but breaks suddenly when somewhere earlier
a `set --` instruction is used in the future.
Neither in commit 58f385f680
nor in PR https://github.com/NixOS/nixpkgs/pull/197547
have I found anything stating that this "defect" was intentional.
2024-10-05 14:14:01 +00:00
Zhaofeng Li
b8c1ef98e4 nixos/binfmt: Add option to use static emulators when available
The fixBinary flag will be enabled if a static emulator is in use.
2024-10-01 15:05:32 +09:00
Robert Hensing
65eea03839 lib/modules: Improve error when loading a flake as a module 2024-09-26 18:31:39 +02:00
Artturin
e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00
Robert Hensing
d572d95502
lib.types.anything: remove custom logic for lists (#340202) 2024-09-18 17:08:15 +02:00
nicoo
45b95421fd
lib.fetchers: add hash-normalization helpers (#342072) 2024-09-17 14:59:43 +00:00
nicoo
0aa5242829 lib.fetchers: add tests 2024-09-17 10:51:48 +00:00
Yueh-Shun Li
11c20cd390 lib.toExtension: init
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-09-14 20:56:47 +08:00
Yueh-Shun Li
6749b1c4bc lib/tests/misc.nix: move testFix into new category FIXED-POINTS 2024-09-14 20:54:10 +08:00
HexoKnight
cf5a46368b
lib/types: fix toCoerced's typeMerge 2024-09-10 22:45:27 +01:00
Alexis Destrez
e5e69b748f lib.types.anything: remove custom logic for lists (default to 'mergeEqualOption')
Previously, for values of type list, the merge function would only retain the value
if the number of option definitions was less than or equal to 1, and would throw an
error for conflicting definitions to avoid potentially unwanted list merges.

This change removes that logic, defaulting to the 'mergeEqualOption' function for
values of type list. This approach maintains the same safeguard against merging
different lists while allowing lists with identical values to be merged.
2024-09-07 01:15:32 +02:00
Robert Hensing
92f4ef78de
lib/modules: improve error message when option is being accessed that isn't defined (#338362) 2024-09-02 10:08:49 +02:00
Sandro Jäckel
ab8bf8c35b
lib/modules: improve error message when option is being accessed that isn't defined 2024-09-01 23:29:21 +02:00
github-actions[bot]
dcad9b571a
Merge master into staging-next 2024-08-31 00:13:18 +00:00
Robert Hensing
0abfc619bc
lib.importApply: init (#230588)
* lib.modules.importApply: init

Brings variables from rich scopes to modules defined in separate files.

A helper for functions in files that return a module.

* lib.modules.importApply: Edit doc

Generally improve the quality. Notes:

- Not rendered to the manual yet, so probably the syntax could be
  improved, but I have no way to test this now.

- The docs use `arg` vs `staticArg` in the code. This is intentional,
  because the doc is pretty clear about the role of `arg` whereas
  the code exists in a context where ambiguities are more harmful.

* Format
2024-08-31 01:12:43 +02:00
github-actions[bot]
132f2322d0
Merge master into staging-next 2024-08-26 12:05:25 +00:00
Silvan Mosberger
8f425c25ad lib/tests: Format a file with nixfmt
And fix locations to not break the test.
This is a rare case where another change is required after formatting.
We do this in a separate commit so that we don't need to do it in the
treewide reformatting PR.
2024-08-25 05:07:51 +02:00
Gabriella Gonzalez
75c122699a
lib.cli.escapeShellArg{,s}: Only escape when necessary (#333744)
These utilities will now leave the string undisturbed if it doesn't need to be quoted (because it doesn't have any special characters). This can help generate nicer-looking command lines.

This also transitively improves the output of `lib.toGNUCommandLine` which uses `escapeShellArg` internally
2024-08-16 16:26:08 +02:00
Robert Hensing
7f838d4c54 lib/tests/modules.sh: Improve failure log format
- Clear separation between failures
- Move error regex close to error message, which is at the bottom
  of a fairly long trace
- Move most relevant and consistent info to bottom of terminal:
  the location of the failure.
  Some editors including vscode heuristically resolve file paths
  on Ctrl+click.
- Less wordy - easy to glance
- Capitalized prefixes to distinguish from Nix's own logging
2024-08-12 13:48:25 +02:00
Robert Hensing
6fa24da815 lib/tests/modules.sh: Add loc <depth> optional parameter 2024-08-12 13:47:41 +02:00
Robert Hensing
c516c03bf4 lib/tests/modules.sh: Do not redirect diagnostics to stdout
It still prints its own diagnostics to stdout, but it's always done that.
2024-08-12 13:47:36 +02:00
Robert Hensing
8a6c85d886 lib/tests/modules.sh: Report failure source location 2024-08-12 13:46:38 +02:00
Sigmanificient
6dd44107ac treewide: remove unused lib (and other) arguments 2024-07-26 11:18:09 +02:00
Matt Sturgeon
aad87c2aa8
lib.strings: add trim and trimWith
`strings.trim` returns a copy of the string with all leading and trailing
whitespace removed.

`strings.trimWith` does the same thing, but calling code can decide
whether to trim the start and/or end of the string.
2024-07-25 23:43:33 +01:00
Silvan Mosberger
7c6692836e
Merge pull request #149990 from ShamrockLee/lib-spdx-license 2024-07-25 22:27:10 +02:00
Janik
c20399ea2e
Merge pull request #318712 from woojiq/lib-network-ipv6-parser
lib.network: add ipv6 parser
2024-07-11 20:57:53 +02:00
Robert Hensing
4a014ed92e lib/modules: Use fixed lib instead of args.lib
The practical use for this should be very limited because I don't
think anyone should change `lib`, let alone change `lib.functionArgs`,
but, but it would be even stranger to rely on `args.lib` (or really
`specialArgs.lib` for what's clearly a behavior of the current
`evalModules`, which uses its own ambient lib for basically everything.

The shadowing of `lib` by `args.lib` here seems to be a small mistake,
which is easy to make.
2024-07-03 11:16:31 +02:00
Yueh-Shun Li
10d2e6c906 lib.getLicenseFromSpdxIdOr: init
Add lib.meta.getLicenseFromSpdxIdOr as a variant of
lib.meta.getLicenseFromSpdxId that explicitly state the default
(fallback) value if there's no license matching the given SPDX ID.
2024-06-30 02:59:58 +08:00
woojiq
d559eed93a lib.network: ipv6 parser from string
Add a library function to parse and validate an IPv6 address from a
string. It can parse the first two versions of an IPv6 address according
to https://datatracker.ietf.org/doc/html/rfc4291#section-2.2. The third
form "xxx:x.d.d.d.d" is not yet implemented. Optionally parser can accept prefix length (128 is default).

Add shell script network.sh to test IPv6 parser functionality.
2024-06-29 10:02:00 +03:00