Commit Graph

537 Commits

Author SHA1 Message Date
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
Mikael Voss
7a07cc0da9 lib/strings: allow CA paths in isStorePath 2025-03-05 13:08:41 +01:00
Wroclaw
0de1d18795 lib.types.functionTo: preserve functionArgs
Previously if function in defs had set pattern in argument,
this information would be lost.

This keeps functionArgs in set pattern,
by using functor and `__functionArgs`
that is later used by `lib.functionArgs`.
2025-03-02 00:04:19 +01:00
Johannes Kirschbauer
0e46672592 lib.types: Make functor.wrapped deprecation work in unprocessed types (#382848) 2025-02-21 15:57:20 +07:00
Johannes Kirschbauer
0d52202380 lib.strings: init toSentenceCase (#381802) 2025-02-20 07:58:44 +07:00
isabel
b109863c25 lib.strings: init toSentenceCase 2025-02-19 12:10:39 +00:00
Johannes Kirschbauer
fb79705bca lib.types: improve tests for deprecation warning on all migrated types 2025-02-19 16:54:55 +07:00
Silvan Mosberger
bdddb0c517 Revert "lib.types.attrsWith: remove failing test"
This reverts commit ce8f304bb6.

The problem was simply a typo (nestedTypes.elemType ->
type.nestedTypes.elemType) ! And CI didn't run for lib in the orginal
PR which is why it didn't get caught.
2025-02-17 16:19:40 +01:00
Jeremy Fleischman
6d7f6a92cc lib/types: add types.pathWith
This gives people some flexibility when they need a path type, and
prevents a "combinatorial explosion" of various path stops.

I've re-implemented our existing `path` and `pathInStore` types using
`pathWith`. Our existing `package` type is potentially a candidate for
similar treatment, but it's a little quirkier (there's some stuff with
`builtins.hasContext` and `toDerivation` that I don't completely
understand), and I didn't want to muddy this PR with that.

As a happy side effect of this work, we get a new feature: the ability
to create a type for paths *not* in the store. This is useful for when a
module needs a path to a file, and wants to protect people from
accidentally leaking that file into the nix store.
2025-02-15 16:14:06 +07:00
Johannes Kirschbauer
9d3e649939 lib.types: init mergeTypes (#364620) 2025-02-10 22:10:30 +07:00
Johannes Kirschbauer
3c911b2aca lib.types: init mergeTypes 2025-02-10 21:23:12 +07:00
Johannes Kirschbauer
b3884c8b7d lib/modules: tests change expected error for class mismatch 2025-01-29 11:50:16 +01:00
Silvan Mosberger
0f880eb305 lib.dropEnd (#370558) 2025-01-13 21:30:30 +01:00
piegames
603733851b treewide: Fix incorrect string escapes 2025-01-07 19:49:28 +01:00
Robert Hensing
782a0e6581 lib.dropEnd: init
Naming borrowed from Haskell
- `base`: [`dropWhileEnd`]
- `extra`, `mono-traversable`, ...: [`dropEnd`]

[`dropEnd`]: https://hackage.haskell.org/package/mono-traversable-1.0.21.0/docs/Data-Sequences.html#v:dropEnd
[`dropWhileEnd`]: https://hackage.haskell.org/package/base-4.21.0.0/docs/Data-List.html#v:dropWhileEnd
2025-01-03 12:04:06 +01:00
Robert Hensing
c96e907825 lib/tests/misc: Test lib.drop 2025-01-03 12:03:33 +01:00
Silvan Mosberger
d510f60a4d lib.generators.toPlist: escape XML syntax in strings & keys (#356502) 2024-12-23 13:47:44 +01:00