Commit graph

123 commits

Author SHA1 Message Date
Aliaksandr dc7095a86e
treewide: remove deprecated lib functions that had warning for more than 2 years 2025-10-24 06:30:16 +03:00
dish 92aa5dc190
lib: remove lib.options.mkPackageOptionMD
Removed this, as it was deprecated in 24.11 and was intended to be
removed in 25.05. Better late than never.
2025-10-07 15:53:30 -04:00
Johannes Kirschbauer bb9da33c62
lib/*: fix docs to use "returns" instead of "return" (#442388) 2025-10-06 08:09:54 +00:00
Felix Buehler 06ac3fbebd lib/*: fix docs to use "returns" instead of "return" 2025-09-12 16:16:41 +02: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
Robert Hensing 48ddbb29a1
lib.options.mkOption: clean up visible docs 2025-09-11 17:00:17 +01:00
Matt Sturgeon ba961de6fb
lib.options.mkOption: use one-sentence-per-line for visible docs 2025-09-10 14:41:12 +01:00
Emily 3b7e7e362b haskell.compiler.ghc928: drop 2025-09-07 18:45:52 +01:00
Wolfgang Walther 5a0711127c
treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Florent Charpentier b6bb27bc38 lib.mkEnableOption: fix syntax error in example comment 2025-06-10 00:11:31 +02:00
Peder Bergebakken Sundt c77ac9dfc3 treewide: fix typos 2025-06-02 16:07:07 +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
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 88f912da48
Docs: migrate format of comments to doc-comments 2025-02-12 15:01:43 +07:00
Johannes Kirschbauer 77156bcc8f
doc: improve lib.options reference documentation (#316862)
* Doc: lib/options fixup wording and references

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Silvan Mosberger <github@infinisil.com>
2025-01-13 22:02:34 +01:00
piegames 603733851b treewide: Fix incorrect string escapes 2025-01-07 19:49:28 +01:00
Johannes Kirschbauer d504a1e680
lib.types.attrsWith: add placeholder parameter 2024-12-09 15:25:18 +01:00
Wolfgang Walther 73df63f8ef
lib/options: remove mdDoc
Following through on message itself.
2024-11-22 18:30:11 +01:00
éclairevoyant 77f6192786
lib: deprecate mkPackageOptionMD 2024-06-26 23:14:45 -04:00
éclairevoyant a2a0316319
lib: clarify warning about mdDoc 2024-04-15 14:16:33 -04:00
stuebinm c0c2f2903f lib.mdDoc: remove and replace with warning 2024-04-13 10:07:35 -07:00
Silvan Mosberger f37ba19765
Merge pull request #284512 from hercules-ci/lib-types-unique-merge
lib.types.unique: Check inner type deeply
2024-02-10 02:52:45 +01:00
Robert Hensing 542f5d4f4d lib.option.mergeUniqueOption: Simplify and add warning about merge function
The previous code was optimized for the old uniq behavior, which did not
call merge. That's changed, so the legacy path is not a hot path anymore,
and is not worth any tech debt.
2024-02-04 16:02:13 +01:00
Alois Wohlschlager d33127863e
lib: make deprecation warnings consistent
The deprecation warnings in lib were wildly inconsistent. Different
formulations were used in different places for the same meaning. Some warnings
used builtins.trace instead of lib.warn, which prevents silencing; one even
only had a comment instead. Make everything more uniform.
2024-02-03 19:01:39 +01:00
Robert Hensing b78ba9bc68 lib.types.unique: Check inner type deeply
This doesn't change uniq. Why not?

- In NixOS it seems that uniq is only used with
  simple types that are fully checked by t.check.

- It exists for much longer and is used more widely.

- I believe we should deprecate it, because unique was
  already better.

- unique can be a proving ground.
2024-01-28 14:09:27 +01:00
Silvan Mosberger 055ba65fed lib: Take advantage of section descriptions
See https://github.com/nix-community/nixdoc/releases/tag/v2.6.0
2023-11-20 03:02:11 +01:00
Anselm Schüler 7e24b3619f
lib/options: refactor mkPackageOption 2023-10-10 13:14:17 +02:00
Anselm Schüler f07537da75
lib/options: add pkgsText parameter to mkPackageOption 2023-10-06 14:08:50 +02:00
Anselm Schüler 19241f5618
lib/options: correct and improve documentation of mkPackageOption 2023-10-06 14:07:06 +02:00
pennae d36f950d40 lib: turn *MD functions into aliases
with docbook gone and MD the default these aren't needed any more. we
can't remove them yet because there's thousands of uses, but maybe some
day we can.
2023-06-13 16:56:32 +02:00
pennae 7542a1aa8f lib/options: remove literalDocBook
no longer supported. warning when used would not be appropriate, and
docbook has been on the way out for long enough that throwing an error
should not be necessary either.
2023-06-13 16:56:30 +02:00
Naïm Favier 4a56b2655e
lib/options: nullable mkPackageOption
It is sometimes useful to allow setting a package option to `null` to
skip installing the package. See
https://github.com/nix-community/home-manager/pull/3668#issuecomment-1554044171
for example.
2023-05-19 12:22:21 +02:00
Naïm Favier 7cd5b9a6e8
lib/options: fix rendering of options with only a defaultText
Some options have their default value set in the `config` instead of
`default`, for example to push `mkDefault`s down an attribute set.
In those cases, it's useful to provide a `defaultText` for informational
purposes.
2023-05-06 17:09:10 +02:00
pennae f0e8db002b lib/options: fix mkPackageOption docs
nixdoc takes everything from Type: to Example: as the type, which
misrendered a large part of the docs. it also drops sorely needed spaces
where the type had line breaks, so all has to be on one line (or use
non-standard literal spaces, which is probably worse).

also clarify what the `?` for arguments mean while we're here.
2023-03-05 01:21:46 +01:00
Anselm Schüler 9769e90233 lib/options: Add more options to mkPackageOption 2023-02-26 03:00:22 +01:00
Naïm Favier 6c7d4d4f9d
lib/options: update showOption comment 2023-02-18 18:13:11 +01:00
Domen Kožar fe734efc9c types: suggest how to resolve the conflict 2023-02-09 08:24:12 +00:00
Domen Kožar b3cc29c288 types: explicitly state unique options are expected to be unique 2023-02-09 07:25:50 +00:00
Colin Arnott 6ff66fcbd7
lib: standardise attrset type syntax
There are a number of different syntaxes used for attrset type
signatures in our doc strings, this change standardises upon one that
uses :: for specifying attribute type, and ; terminators to be
consistent with nix syntax. There are no bugs in the functions
themselves, just that different syntaxes may confuse new users.
2023-01-30 23:53:44 +00:00
pennae 9da5f12ecf modules: add mkPackageOptionMD
another transitional option factory, like mkAliasOptionModuleMD.
2023-01-05 02:33:13 +01:00
hsjobeki 5ff21bfc73 attrsets: fix and add some doc types 2022-12-24 14:08:11 +01:00
Robert Hensing 5fb20d2f8c lib.modules: Add error context to rendered default and example attrs 2022-12-10 23:23:42 +01:00
Naïm Favier 6a117e2759 nixos/doc: render option values using lib.generators.toPretty
Render un`_type`d defaults and examples as `literalExpression`s using
`lib.generators.toPretty` so that consumers don't have to reinvent Nix
pretty-printing. `renderOptionValue` is kept internal for now intentionally.

Make `toPretty` print floats as valid Nix values (without a tilde).

Get rid of the now-obsolete `substSpecial` function.

Move towards disallowing evaluation of packages in the manual by
raising a warning on `pkgs.foo.{outPath,drvPath}`; later, this should
throw an error. Instead, module authors should use `literalExpression`
and `mkPackageOption`.
2022-12-08 17:52:52 +01:00
sternenseemann c7a0d75bd1 haskell.compiler.ghc92: 9.2.4 -> 9.2.5 2022-11-07 17:29:47 +01:00
Maximilian Bosch 6396482dde
lib/options/showOption: fix quoting of attr-names that are not identifiers
Personally, I think that warnings such as

    warning: The option `services.redis.enable' defined in `/home/ma27/Projects/nixpkgs/test.nix@node-vm' has been renamed to `services.redis.servers..enable'.

are fairly confusing because of the `..` and it's more correct to
actually quote that. With this change the warning now looks like this:

    warning: The option `services.redis.enable' defined in `/home/ma27/Projects/nixpkgs/test.nix@node-vm' has been renamed to `services.redis.servers."".enable'.

While implementing that I realized that you'd have
a similar problem whenever you use attribute-names that aren't
identifiers, e.g.

    services.nginx.virtualHosts."example.org".locations."/".invalid = 23;

now results in the following error:

    error: The option `interactive.nodes.vm.services.nginx.virtualHosts."example.org".locations."/".invalid' does not exist. Definition values:
           - In `/home/ma27/Projects/nixpkgs/test.nix@node-vm': 23

Of course there are some corner-cases where this won't work: when
generating the manual, you display submodules like this:

    services.nginx.virtualHosts.<name>

Since `<name>` isn't a value, but an indicator for a submodule, it must
not be quoted. This also applies to the following identifiers:

* `*` for `listOf submodule`
* `<function body>` for `functionTo`

This might not be correct if you actually have a submodule with an
attribute name called `<name>`, but I think it's an improvement over the
current situation and for this you'd probably need to make even more
complex changes to the module system.
2022-10-07 10:09:03 +02:00
figsoda d29b0096d3 lib/options.nix: remove unused binding 2022-09-26 22:18:55 -04:00
pennae 767485a0de lib/options: deprecate docbook text and literalDocBook
deprecate literalDocBook by adding a warning (that will not fire yet) to
its uses and other docbook literal strings by adding optional warning
message to mergeJSON.
2022-09-10 18:23:13 +02:00
pennae e04a09082e lib/modules: convert option description to MD 2022-08-31 17:27:37 +02:00
pennae 9bb82c35b7 lib/options: add mdDoc support to mkEnableOption 2022-08-30 15:05:05 +02:00
sternenseemann 7f909b041b haskell.compiler: ghc923 -> ghc924
https://www.haskell.org/ghc/download_ghc_9_2_4.html
2022-07-28 18:09:33 +02:00