about summary refs log tree commit diff
path: root/lib/options.nix
AgeCommit message (Collapse)AuthorFilesLines
2024-06-26lib: deprecate mkPackageOptionMDéclairevoyant1-3/+3
2024-04-15lib: clarify warning about mdDocéclairevoyant1-1/+1
2024-04-13lib.mdDoc: remove and replace with warningstuebinm1-2/+4
2024-02-10Merge pull request #284512 from hercules-ci/lib-types-unique-mergeSilvan Mosberger1-5/+23
lib.types.unique: Check inner type deeply
2024-02-04lib.option.mergeUniqueOption: Simplify and add warning about merge functionRobert Hensing1-16/+11
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-03lib: make deprecation warnings consistentAlois Wohlschlager1-1/+1
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-01-28lib.types.unique: Check inner type deeplyRobert Hensing1-5/+28
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.
2023-11-20lib: Take advantage of section descriptionsSilvan Mosberger1-1/+1
See https://github.com/nix-community/nixdoc/releases/tag/v2.6.0
2023-10-10lib/options: refactor mkPackageOptionAnselm Schüler1-13/+13
2023-10-06lib/options: add pkgsText parameter to mkPackageOptionAnselm Schüler1-7/+22
2023-10-06lib/options: correct and improve documentation of mkPackageOptionAnselm Schüler1-13/+36
2023-06-13lib: turn *MD functions into aliasespennae1-12/+7
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-13lib/options: remove literalDocBookpennae1-13/+1
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-05-19lib/options: nullable mkPackageOptionNaïm Favier1-7/+14
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-06lib/options: fix rendering of options with only a defaultTextNaïm Favier1-3/+3
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-03-05lib/options: fix mkPackageOption docspennae1-7/+5
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-02-26lib/options: Add more options to mkPackageOptionAnselm Schüler1-15/+48
2023-02-18lib/options: update showOption commentNaïm Favier1-6/+4
2023-02-09types: suggest how to resolve the conflictDomen Kožar1-2/+5
2023-02-09types: explicitly state unique options are expected to be uniqueDomen Kožar1-1/+1
2023-01-30lib: standardise attrset type syntaxColin Arnott1-3/+3
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-05modules: add mkPackageOptionMDpennae1-1/+6
another transitional option factory, like mkAliasOptionModuleMD.
2022-12-24attrsets: fix and add some doc typeshsjobeki1-2/+2
2022-12-10lib.modules: Add error context to rendered default and example attrsRobert Hensing1-3/+14
2022-12-08nixos/doc: render option values using `lib.generators.toPretty`Naïm Favier1-4/+17
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-11-07haskell.compiler.ghc92: 9.2.4 -> 9.2.5sternenseemann1-1/+1
2022-10-07lib/options/showOption: fix quoting of attr-names that are not identifiersMaximilian Bosch1-3/+9
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-09-26lib/options.nix: remove unused bindingfigsoda1-1/+0
2022-09-10lib/options: deprecate docbook text and literalDocBookpennae1-1/+4
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-08-31lib/modules: convert option description to MDpennae1-1/+1
2022-08-30lib/options: add mdDoc support to mkEnableOptionpennae1-1/+4
2022-07-28haskell.compiler: ghc923 -> ghc924sternenseemann1-1/+1
https://www.haskell.org/ghc/download_ghc_9_2_4.html
2022-06-27lib/options: Add hint for debugging infinite recursion in docsRobert Hensing1-0/+2
2022-06-21lib/options: Add showOptionWithDefLocsRobert Hensing1-0/+6
2022-06-12treewide: attempt at markdown option docspennae1-0/+15
2022-05-28haskell.compiler: ghc922 -> ghc923sternenseemann1-1/+1
https://www.haskell.org/ghc/download_ghc_9_2_3.html Since the tarball is generated by Hadrian, neither autoreconf nor ./boot is executed so ./configure and ghc.mk is missing.
2022-03-26Merge remote-tracking branch 'origin/master' into haskell-updatessternenseemann1-2/+0
2022-03-18lib/modules: Finally remove deprecated types.optionSetSilvan Mosberger1-2/+0
types.optionSet has been deprecated for almost 10 years now (0e333688cea468a28516bf6935648c03ed62a7bb)! A removal was already attempted in 2019 (27982b408e465554b8831f492362bc87ed0ec02a), but it was promptly reinstantiated since some third-party uses were discovered (f531ce75e4178c6867cc1d0f7fec96b2d5c3f1cb). It's finally time to remove it for good :)
2022-03-17Merge master into haskell-updatesgithub-actions[bot]1-1/+1
2022-03-09haskell.compiler: ghc921 -> ghc922sternenseemann1-1/+1
https://www.haskell.org/ghc/download_ghc_9_2_2.html
2022-02-28lib/options: Throw error for options without a typeJanne Heß1-1/+1
Makes all options rendered in the manual throw an error if they don't have a type specified. This is a follow-up to #76184 Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
2022-01-25Merge pull request #156503 from hercules-ci/nixos-add-system.build-optionsRobert Hensing1-5/+7
nixos: Add `system.build.`{`toplevel`,`installBootLoader`}, improve error message
2022-01-24lib.modules: Define mergeOneOption in terms of mergeUniqueOptionRobert Hensing1-5/+1
2022-01-24lib.types: Add unique like uniq, but custom errorsRobert Hensing1-0/+6
Couldn't extend types.uniq and it had a silly name anyway. Now we can have better error messages.
2022-01-23nixos/docs/option-declarations: Document mkEnableOption and mkPackageOptionAnselm Schüler1-15/+40
This is a squashed commit. These are the original commit messages: lib/option: Improve comment better comment Update documentation Updated nixos/doc/manual/development/options-declarations.md with info on mkEnableOption and mkPackageOption. Updated the comment on mkEnableOption in lib/options.nix remove trailing whitespace nixos/doc/option-declarations: Update IDs & formatting nixos/docs/option-declarations: Escape angle brackets Build DB from MD (Amended) Fix typo Co-authored-by: pennae <82953136+pennae@users.noreply.github.com> (Amended) Build DB from MD (again)
2022-01-23lib/options: Add mkPackageOptionAnselm Schüler1-0/+19
This is a squashed commit. These are the original commit messages: lib/options: Add mkPackageOption lib/options: Add missing semicolon lib/options.nix: Make mkPackageOption more complicated lib/options: Fix indent. & spacing lib/options.nix: Remove example and align comment lib/options: ravenous overuse of arguments lib/options: Format better lib/options: Add default examplePath decl lib/options: Make better mkPackageOption function lib/options: Remove trailing whitespace lib/options: Improve mkPackageOptions lib/options: Remove pkgs prefixing Co-authored-by: pennae <82953136+pennae@users.noreply.github.com> lib/options: Slim down mkPackageOption further lib/options: mkPackageOption: Add "pkgs." to example lib/options: mkPackageOption: Make name & pkgs single arguments lib/options: mkPackageOption: Swap name & pkgs lib/options: Remove unnecessary import Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
2022-01-02nixos/documentation: split options doc buildpennae1-1/+1
most modules can be evaluated for their documentation in a very restricted environment that doesn't include all of nixpkgs. this evaluation can then be cached and reused for subsequent builds, merging only documentation that has changed into the cached set. since nixos ships with a large number of modules of which only a few are used in any given config this can save evaluation a huge percentage of nixos options available in any given config. in tests of this caching, despite having to copy most of nixos/, saves about 80% of the time needed to build the system manual, or about two second on the machine used for testing. build time for a full system config shrank from 9.4s to 7.4s, while turning documentation off entirely shortened the build to 7.1s.
2021-11-01modules: Add visible = "shallow" to hide only sub-optionsRobert Hensing1-3/+7
2021-10-03lib/options: add literalExpression and literalDocBook, deprecate literalExampleNaïm Favier1-5/+19
2021-08-26lib/generators: move limit detection into `withRecursion`Maximilian Bosch1-1/+3
As suggested in #131205. Now it's possible to pretty-print a value with `lib.generators` like this: with lib.generators; toPretty { } (withRecursion { depthLimit = 10; } /* arbitrarily complex value */) Also, this can be used for any other pretty-printer now if needed.