summaryrefslogtreecommitdiff
path: root/lib/options.nix (follow)
Commit message (Expand)AuthorAgeFilesLines
* Merge pull request #284512 from hercules-ci/lib-types-unique-merge•••lib.types.unique: Check inner type deeplySilvan Mosberger2024-02-101-5/+23
|\
| * 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. Robert Hensing2024-02-041-16/+11
| * 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. Robert Hensing2024-01-281-5/+28
* | 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. Alois Wohlschlager2024-02-031-1/+1
|/
* lib: Take advantage of section descriptions•••See https://github.com/nix-community/nixdoc/releases/tag/v2.6.0 Silvan Mosberger2023-11-201-1/+1
* lib/options: refactor mkPackageOptionAnselm Schüler2023-10-101-13/+13
* lib/options: add pkgsText parameter to mkPackageOptionAnselm Schüler2023-10-061-7/+22
* lib/options: correct and improve documentation of mkPackageOptionAnselm Schüler2023-10-061-13/+36
* 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. pennae2023-06-131-12/+7
* 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. pennae2023-06-131-13/+1
* 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. Naïm Favier2023-05-191-7/+14
* 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. Naïm Favier2023-05-061-3/+3
* 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. pennae2023-03-051-7/+5
* lib/options: Add more options to mkPackageOptionAnselm Schüler2023-02-261-15/+48
* lib/options: update showOption commentNaïm Favier2023-02-181-6/+4
* types: suggest how to resolve the conflictDomen Kožar2023-02-091-2/+5
* types: explicitly state unique options are expected to be uniqueDomen Kožar2023-02-091-1/+1
* 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. Colin Arnott2023-01-301-3/+3
* modules: add mkPackageOptionMD•••another transitional option factory, like mkAliasOptionModuleMD. pennae2023-01-051-1/+6
* attrsets: fix and add some doc typeshsjobeki2022-12-241-2/+2
* lib.modules: Add error context to rendered default and example attrsRobert Hensing2022-12-101-3/+14
* 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`. Naïm Favier2022-12-081-4/+17
* haskell.compiler.ghc92: 9.2.4 -> 9.2.5sternenseemann2022-11-071-1/+1
* 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. Maximilian Bosch2022-10-071-3/+9
* lib/options.nix: remove unused bindingfigsoda2022-09-261-1/+0
* 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. pennae2022-09-101-1/+4
* lib/modules: convert option description to MDpennae2022-08-311-1/+1
* lib/options: add mdDoc support to mkEnableOptionpennae2022-08-301-1/+4
* haskell.compiler: ghc923 -> ghc924•••https://www.haskell.org/ghc/download_ghc_9_2_4.html sternenseemann2022-07-281-1/+1
* lib/options: Add hint for debugging infinite recursion in docsRobert Hensing2022-06-271-0/+2
* lib/options: Add showOptionWithDefLocsRobert Hensing2022-06-211-0/+6
* treewide: attempt at markdown option docspennae2022-06-121-0/+15
* haskell.compiler: ghc922 -> ghc923•••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. sternenseemann2022-05-281-1/+1
* Merge remote-tracking branch 'origin/master' into haskell-updatessternenseemann2022-03-261-2/+0
|\
| * lib/modules: Finally remove deprecated types.optionSet•••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 :) Silvan Mosberger2022-03-181-2/+0
* | Merge master into haskell-updatesgithub-actions[bot]2022-03-171-1/+1
|\|
| * lib/options: Throw error for options without a type•••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> Janne Heß2022-02-281-1/+1
* | haskell.compiler: ghc921 -> ghc922•••https://www.haskell.org/ghc/download_ghc_9_2_2.html sternenseemann2022-03-091-1/+1
|/
* Merge pull request #156503 from hercules-ci/nixos-add-system.build-options•••nixos: Add `system.build.`{`toplevel`,`installBootLoader`}, improve error messageRobert Hensing2022-01-251-5/+7
|\
| * lib.modules: Define mergeOneOption in terms of mergeUniqueOptionRobert Hensing2022-01-241-5/+1
| * lib.types: Add unique like uniq, but custom errors•••Couldn't extend types.uniq and it had a silly name anyway. Now we can have better error messages. Robert Hensing2022-01-241-0/+6
* | nixos/docs/option-declarations: Document mkEnableOption and mkPackageOption•••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) Anselm Schüler2022-01-231-15/+40
* | lib/options: Add mkPackageOption•••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> Anselm Schüler2022-01-231-0/+19
|/
* nixos/documentation: split options doc build•••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. pennae2022-01-021-1/+1
* modules: Add visible = "shallow" to hide only sub-optionsRobert Hensing2021-11-011-3/+7
* lib/options: add literalExpression and literalDocBook, deprecate literalExampleNaïm Favier2021-10-031-5/+19
* lib/generators: move limit detection into `withRecursion`•••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. Maximilian Bosch2021-08-261-1/+3
* lib/options: use `depthLimit` for `toPretty` when showing a definition•••When having a bogus declaration such as { lib, ... }: { foo.bar = mkOption { type = types.str; }; } the evaluation will terminate with a not-so helpful error: stack overflow (possible infinite recursion) To make sure a useful error is still provided, I added a `depthLimit` of `10` which should be perfectly sufficient to `toPretty` when it's used in an error-case for `showDefs`. Maximilian Bosch2021-08-251-1/+1
* lib/options: Better mergeEqualOption error for uncomparable types•••For an option definition that uses `lib.options.mergeEqualOption` underneath, like `types.anything`, an error is thrown when multiple functions are assigned, indicating that functions can't be compared for equivalence: error: The option `test' has conflicting definition values: - In `xxx': <function> - In `xxx': <function> (use '--show-trace' to show detailed location information) However, the error message didn't use the correct files. While above error indicates that both definitions are in the xxx file, that's in fact not true. Above error was generated with options.test = lib.mkOption { type = lib.types.anything; }; imports = [ { _file = "yyy"; test = y: y; } { _file = "xxx"; test = x: x; } ]; With this change, the error uses the correct file locations: error: The option `test' has conflicting definition values: - In `xxx': <function> - In `yyy': <function> (use '--show-trace' to show detailed location information) Silvan Mosberger2021-08-101-1/+2
* Revert "Module-builtin assertions, disabling assertions and submodule asserti...Silvan Mosberger2020-12-181-1/+1