Commit graph

268 commits

Author SHA1 Message Date
Johannes Kirschbauer 013beed1db
lib/types: check paths in pathWith with hasStorePathPrefix (#387304) 2025-04-21 10:45:23 +02: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
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
Johannes Kirschbauer 484a0477d8
lib/types: types.either deprecate functor.wrapped in favor of functor.payload.elemType 2025-03-20 14:11:34 +00:00
Silvan Mosberger 987a096334
lib/types: types deprecate functor.wrapped in favor of functor.payload.elemType for trivial cases (#375084) 2025-03-20 14:28:57 +01:00
Matt Sturgeon c347d605c9
lib.types: add luaInline
Represents inline lua as expected by `lib.generators.toLua`, for
embedding raw lua expressions within structurally generated lua.
2025-03-15 10:29:28 +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
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
Silvan Mosberger 64a1c1da3e
lib.types: Make functor.wrapped deprecation work in unprocessed types
Otherwise nested types such as `attrsOf (attrsOf int)` won't have a
backwards compatible `type.nestedTypes.elemType.functor.wrapped`.

Follow-up work to https://github.com/NixOS/nixpkgs/pull/366015
2025-02-19 16:10:27 +07:00
Johannes Kirschbauer 3f9d8a1fea
lib/pathWith: keep old typename, to avoid breakage in downstream projects 2025-02-19 09:03:18 +07: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 5782ef8dc3
lib/types: deprecate functor.wrapped in types.listOf 2025-01-06 16:01:02 +01:00
Johannes Kirschbauer 3d92f38fbd
lib/types: refactor elemTypeFunctor for types.attrsWith 2025-01-06 15:24:48 +01:00
Silvan Mosberger 33fe023937
lib/types: make pattern of strMatching accessible (#350467) 2024-12-09 17:53:38 +01:00
Silvan Mosberger 062945b725
lib.types: chore use consistent payload form (#363565) 2024-12-09 16:23:19 +01:00
Johannes Kirschbauer d504a1e680
lib.types.attrsWith: add placeholder parameter 2024-12-09 15:25:18 +01:00
Johannes Kirschbauer f407f6f57e
lib.types: chore use consistent payload form 2024-12-09 14:09:16 +01:00
Johannes Kirschbauer 58c115499f
lib.types: improve performance on attrsWith 2024-12-03 10:03:19 +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 e438d6b08d
lib/types: Add deprecation to attrsWith
Co-Authored-By: @infinisil
2024-12-03 10:02:55 +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
Johannes Kirschbauer 399e582e18
lib.types: improve performance on attrsWith 2024-12-02 16:39:29 +01:00
Silvan Mosberger d5eccbbbae lib/types: standardise attrsOf functor.wrapped warning and add a test 2024-12-02 16:18:03 +01:00
Silvan Mosberger 45f0035a83
lib/types: Add deprecation to attrsWith
Co-Authored-By: @infinisil
2024-11-26 10:27:01 +01: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
Johannes Kirschbauer b978799f71
lib.types.defaultTypeMerge: refactor functor.{payload,wrapped} merging 2024-11-19 08:58:38 +01:00
Johannes Kirschbauer ad7b2f3438
lib/types: make pattern of strMatching accessible 2024-10-23 11:02:39 +02:00
Robert Hensing d572d95502
lib.types.anything: remove custom logic for lists (#340202) 2024-09-18 17:08:15 +02: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
Matt Sturgeon f1cd097be2
lib/types: update reference to docs
The XML docs have been migrated to markdown since bfd21cd2c1
2024-08-16 16:09:15 +01:00
Philip Taron 6cf8ae9090
lib.types: remove __attrsFailEvaluation
The test (`nix-build pkgs/test/release/default.nix`) continues to pass without this preventative measure.
2024-07-01 10:37:58 -07:00
Silvan Mosberger 4f1d724b82
Merge pull request #284551 from hercules-ci/types-attrTag
Add `types.attrTag`
2024-04-09 20:48:44 +02:00
Johannes Kirschbauer c0f5f271d1
doc: migrate trivial files to doc-comment format (#299986)
* doc: migrate trivial files to doc-comment format

* fix: revert some comments

* Apply suggestions from code review

Thanks @danielSidhion

Co-authored-by: Daniel Sidhion <DanielSidhion@users.noreply.github.com>

* Update lib/types.nix

---------

Co-authored-by: Daniel Sidhion <DanielSidhion@users.noreply.github.com>
Co-authored-by: Silvan Mosberger <github@infinisil.com>
2024-04-04 16:36:07 +02:00
Robert Hensing 35fe538330
types.attrTag: Remove unnecessary definitions override
Committing because tests pass.

Co-authored-by: Silvan Mosberger <github@infinisil.com>
2024-04-04 13:00:19 +02:00
Robert Hensing 22d7f146a4 lib.types.attrTag: Fix declarationPositions after merge 2024-04-04 12:56:56 +02:00
Robert Hensing 2d791b5f7b types.attrTag: Remove substSubmodules
I haven't managed to trigger the error, and it turns out that this
method is optional.
Specifically, getSubmodules is unimplemented (and unimplementable),
the tests pass, and we seem to have good location info.
2024-04-04 12:00:54 +02:00
Robert Hensing 47e4a18d01 types.attrTagWith: remove
Keep it simple for now.
2024-04-04 12:00:54 +02:00
Robert Hensing 1465777b63 lib.types.attrTag: Custom error when passing bare type 2024-04-04 11:54:46 +02:00
Robert Hensing 475a55b2f0 lib.types.attrTag: Remove tags from description
You can find them in the sub-options now.
2024-04-04 11:54:46 +02:00
Robert Hensing 4c7d990bad lib.types.attrTag: Provide declarations, definitions 2024-04-04 11:54:45 +02:00