Commit Graph

284 Commits

Author SHA1 Message Date
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
Johannes Kirschbauer
2b2df96038 lib/types: submodule fix description with freeformType (#443134) 2025-09-25 14:57:10 +00:00
Johannes Kirschbauer
717bb9db24 lib/types: submodule fix description with freeformType 2025-09-16 16:27:32 +02:00
Johannes Kirschbauer
8a5c4598d8 lib/types: either allow unchecked values again
This fixes a slight regression of the either type
Where it allowed access to any value when used in freeformType
2025-09-06 11:49:31 +02:00
Johannes Kirschbauer
cd2e5bd46c types/merge: move 'configuration' of submodules into nested attribute set 2025-08-13 15:09:21 +02:00
Johannes Kirschbauer
50bef19448 lib/modules: add nested 'headError.message'
This should make headError extensible other information needs to be passed
This seems to improve performance slightly
2025-08-13 15:09:20 +02:00
Johannes Kirschbauer
ebafc3eb74 lib/modules: optimize performance by inlining bindings 2025-08-13 15:09:20 +02:00
Johannes Kirschbauer
5d72133a22 lib/addCheck: add support for new merge 2025-08-13 15:09:20 +02:00
Johannes Kirschbauer
70ab11c2f2 lib/modules: add new merge.v2 for 'types.{either,coercedTo}' 2025-08-13 15:09:20 +02:00
Johannes Kirschbauer
648dbed1d6 lib/types: add 'checkDefsForError' utility for checking defs with a given check 2025-08-13 15:09:20 +02:00
Robert Hensing
644527dd57 lib.modules: init types checkAndMerge to allow adding 'valueMeta' attributes
This allows individual types to add attributes that would be discarded during normal evaluation.
Some examples:

types.submodule performs a submodule evluation which yields an 'evalModules' result.
It returns '.config' but makes the original result accessible via 'valueMeta' allowing introspection of '.options' and all other kinds of module evaluation results

types.attrsOf returns an attribute set of the nestedType.
It makes each valueMeta available under the corresponding attribute name.
2025-08-13 15:09:20 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
sodiboo
b3c9916455 lib.types.attrTag: expose suboptions at correct level 2025-06-22 21:23:18 +02:00
Pol Dellaiera
6d9d3014ba treewide: fix typos in comments (#413240) 2025-06-02 18:43:07 +02:00
Peder Bergebakken Sundt
c77ac9dfc3 treewide: fix typos 2025-06-02 16:07:07 +02:00
Johannes Kirschbauer
7063762d13 lib/types: add doc warning to addCheck 2025-05-30 16:25:44 +02:00
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