about summary refs log tree commit diff
path: root/lib/options.nix
Commit message (Collapse)AuthorAge
* lib: turn *MD functions into aliasespennae2023-06-13
| | | | | | 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.
* lib/options: remove literalDocBookpennae2023-06-13
| | | | | | 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.
* lib/options: nullable mkPackageOptionNaïm Favier2023-05-19
| | | | | | | 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.
* lib/options: fix rendering of options with only a defaultTextNaïm Favier2023-05-06
| | | | | | | 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.
* lib/options: fix mkPackageOption docspennae2023-03-05
| | | | | | | | | 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.
* lib/options: Add more options to mkPackageOptionAnselm Schüler2023-02-26
|
* lib/options: update showOption commentNaïm Favier2023-02-18
|
* types: suggest how to resolve the conflictDomen Kožar2023-02-09
|
* types: explicitly state unique options are expected to be uniqueDomen Kožar2023-02-09
|
* lib: standardise attrset type syntaxColin Arnott2023-01-30
| | | | | | | | 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.
* modules: add mkPackageOptionMDpennae2023-01-05
| | | | another transitional option factory, like mkAliasOptionModuleMD.
* attrsets: fix and add some doc typeshsjobeki2022-12-24
|
* lib.modules: Add error context to rendered default and example attrsRobert Hensing2022-12-10
|
* nixos/doc: render option values using `lib.generators.toPretty`Naïm Favier2022-12-08
| | | | | | | | | | | | | | | 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`.
* haskell.compiler.ghc92: 9.2.4 -> 9.2.5sternenseemann2022-11-07
|
* lib/options/showOption: fix quoting of attr-names that are not identifiersMaximilian Bosch2022-10-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* lib/options.nix: remove unused bindingfigsoda2022-09-26
|
* lib/options: deprecate docbook text and literalDocBookpennae2022-09-10
| | | | | | 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.
* lib/modules: convert option description to MDpennae2022-08-31
|
* lib/options: add mdDoc support to mkEnableOptionpennae2022-08-30
|
* haskell.compiler: ghc923 -> ghc924sternenseemann2022-07-28
| | | | https://www.haskell.org/ghc/download_ghc_9_2_4.html
* lib/options: Add hint for debugging infinite recursion in docsRobert Hensing2022-06-27
|
* lib/options: Add showOptionWithDefLocsRobert Hensing2022-06-21
|
* treewide: attempt at markdown option docspennae2022-06-12
|
* haskell.compiler: ghc922 -> ghc923sternenseemann2022-05-28
| | | | | | | 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.
* Merge remote-tracking branch 'origin/master' into haskell-updatessternenseemann2022-03-26
|\
| * lib/modules: Finally remove deprecated types.optionSetSilvan Mosberger2022-03-18
| | | | | | | | | | | | | | | | | | | | | | 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 :)
* | Merge master into haskell-updatesgithub-actions[bot]2022-03-17
|\|
| * lib/options: Throw error for options without a typeJanne Heß2022-02-28
| | | | | | | | | | | | | | | | | | 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>
* | haskell.compiler: ghc921 -> ghc922sternenseemann2022-03-09
|/ | | | https://www.haskell.org/ghc/download_ghc_9_2_2.html
* Merge pull request #156503 from hercules-ci/nixos-add-system.build-optionsRobert Hensing2022-01-25
|\ | | | | nixos: Add `system.build.`{`toplevel`,`installBootLoader`}, improve error message
| * lib.modules: Define mergeOneOption in terms of mergeUniqueOptionRobert Hensing2022-01-24
| |
| * lib.types: Add unique like uniq, but custom errorsRobert Hensing2022-01-24
| | | | | | | | | | Couldn't extend types.uniq and it had a silly name anyway. Now we can have better error messages.
* | nixos/docs/option-declarations: Document mkEnableOption and mkPackageOptionAnselm Schüler2022-01-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | lib/options: Add mkPackageOptionAnselm Schüler2022-01-23
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* nixos/documentation: split options doc buildpennae2022-01-02
| | | | | | | | | | | | | | | | 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.
* modules: Add visible = "shallow" to hide only sub-optionsRobert Hensing2021-11-01
|
* lib/options: add literalExpression and literalDocBook, deprecate literalExampleNaïm Favier2021-10-03
|
* lib/generators: move limit detection into `withRecursion`Maximilian Bosch2021-08-26
| | | | | | | | | | | | | 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.
* lib/options: use `depthLimit` for `toPretty` when showing a definitionMaximilian Bosch2021-08-25
| | | | | | | | | | | | | | | | | | | 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`.
* lib/options: Better mergeEqualOption error for uncomparable typesSilvan Mosberger2021-08-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Revert "Module-builtin assertions, disabling assertions and submodule ↵Silvan Mosberger2020-12-18
| | | | assertions"
* lib/options: Don't show internal suboption in the manualSilvan Mosberger2020-11-30
| | | | | | | | Initially https://github.com/NixOS/nixpkgs/pull/82897 prevented non-visible options from being rendered in the manual, but visible-but-internal options were still being recursed into. This fixes this, aligning the recurse condition here with the one in make-options-doc/default.nix
* lib/options.nix: Use merge-friendly inherit syntaxRobert Hensing2020-10-22
|
* lib: Use Nix's static scope checking, fix error message, optimizeRobert Hensing2020-10-22
| | | | | | | | | | | | | | | | | | | Nix can perform static scope checking, but whenever code is inside a `with` expression, the analysis breaks down, because it can't know statically what's in the attribute set whose attributes were brought into scope. In those cases, Nix has to assume that everything works out. Except it doesnt. Removing `with` from lib/ revealed an undefined variable in an error message. If that doesn't convince you that we're better off without `with`, I can tell you that this PR results in a 3% evaluation performance improvement because Nix can look up local variables by index. This adds up with applications like the module system. Furthermore, removing `with` makes the binding site of each variable obvious, which helps with comprehension.
* lib/options.nix: Use head instead of elemAt _ 0Robert Hensing2020-10-22
|
* lib/modules: Improve error messages using showDefsSilvan Mosberger2020-09-21
|
* lib/options: Introduce showDefsSilvan Mosberger2020-09-21
| | | | For pretty-printing definitions, including file and values
* lib/options: Fix mergeEqualOption for singular functionsSilvan Mosberger2020-09-15
| | | | Previously it would error out for a single function definition
* lib/options: fix showOption exampleDaiderd Jordan2020-04-14
|