diff options
| author | nixpkgs-ci[bot] <190413589+nixpkgs-ci[bot]@users.noreply.github.com> | 2026-01-20 00:18:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-20 00:18:19 +0000 |
| commit | c95fc42eb1ade94635b8a0e64e63e337459c1c3e (patch) | |
| tree | 57adba918dec077a4275a0ad3b8c70e688371b31 /lib | |
| parent | Merge master into staging-next (diff) | |
| parent | python3Packages.imapclient: 3.0.1 -> 3.1.0 (#481788) (diff) | |
| download | nixpkgs-c95fc42eb1ade94635b8a0e64e63e337459c1c3e.tar.gz | |
Merge master into staging-next
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/options.nix | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/lib/options.nix b/lib/options.nix index 164bd6248534..195ba79765e9 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -672,11 +672,30 @@ rec { is necessary for complex values, e.g. functions, or values that depend on other values or packages. + # Examples + :::{.example} + ## `literalExpression` usage example + + ```nix + llvmPackages = mkOption { + type = types.str; + description = '' + Version of llvm packages to use for + this module + ''; + example = literalExpression '' + llvmPackages = pkgs.llvmPackages_20; + ''; + }; + ``` + + ::: + # Inputs `text` - : 1\. Function argument + : The text to render as a Nix expression */ literalExpression = text: @@ -690,6 +709,49 @@ rec { /** For use in the `defaultText` and `example` option attributes. Causes the + given string to be rendered verbatim in the documentation as a code + block with the language bassed on the provided input tag. + + If you wish to render Nix code, please see `literalExpression`. + + # Examples + :::{.example} + ## `literalCode` usage example + + ```nix + myPythonScript = mkOption { + type = types.str; + description = '' + Example python script used by a module + ''; + example = literalCode "python" '' + print("Hello world!") + ''; + }; + ``` + + ::: + + # Inputs + + `languageTag` + + : The language tag to use when producing the code block (i.e. `js`, `rs`, etc). + + `text` + + : The text to render as a Nix expression + */ + literalCode = + languageTag: text: + lib.literalMD '' + ```${languageTag} + ${text} + ``` + ''; + + /** + For use in the `defaultText` and `example` option attributes. Causes the given MD text to be inserted verbatim in the documentation, for when a `literalExpression` would be too hard to read. |
