File: generate-builtins.nix

package info (click to toggle)
nix 2.26.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,524 kB
  • sloc: cpp: 87,540; sh: 8,864; perl: 649; yacc: 466; xml: 410; javascript: 378; lex: 329; ansic: 215; python: 128; sql: 56; makefile: 33; exp: 5; ruby: 1
file content (53 lines) | stat: -rw-r--r-- 1,467 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
let
  inherit (builtins) concatStringsSep attrValues mapAttrs;
  inherit (import <nix/utils.nix>) optionalString squash;
in

builtinsInfo:
let
  showBuiltin =
    name:
    {
      doc,
      type ? null,
      args ? [ ],
      experimental-feature ? null,
      impure-only ? false,
    }:
    let
      type' = optionalString (type != null) " (${type})";

      experimentalNotice = optionalString (experimental-feature != null) ''
        > **Note**
        >
        > This function is only available if the [`${experimental-feature}` experimental feature](@docroot@/development/experimental-features.md#xp-feature-${experimental-feature}) is enabled.
        >
        > For example, include the following in [`nix.conf`](@docroot@/command-ref/conf-file.md):
        >
        > ```
        > extra-experimental-features = ${experimental-feature}
        > ```
      '';

      impureNotice = optionalString impure-only ''
        > **Note**
        >
        > Not available in [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval).
      '';
    in
    squash ''
      <dt id="builtins-${name}">
        <a href="#builtins-${name}"><code>${name}${listArgs args}</code></a>${type'}
      </dt>
      <dd>

      ${experimentalNotice}

      ${doc}

      ${impureNotice}
      </dd>
    '';
  listArgs = args: concatStringsSep "" (map (s: " <var>${s}</var>") args);
in
concatStringsSep "\n" (attrValues (mapAttrs showBuiltin builtinsInfo))