File: generate-store-types.nix

package info (click to toggle)
nix 2.26.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, 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 (47 lines) | stat: -rw-r--r-- 970 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
let
  inherit (builtins)
    attrNames
    listToAttrs
    concatStringsSep
    readFile
    replaceStrings
    ;
  showSettings = import <nix/generate-settings.nix>;
  showStoreDocs = import <nix/generate-store-info.nix>;
in

storeInfo:

let
  storesList = showStoreDocs {
    inherit storeInfo;
    inlineHTML = true;
  };

  index =
    let
      showEntry = store: "- [${store.name}](./${store.filename})";
    in
    concatStringsSep "\n" (map showEntry storesList);

  "index.md" =
    replaceStrings [ "@store-types@" ] [ index ]
      (readFile ./source/store/types/index.md.in);

  tableOfContents =
    let
      showEntry = store: "    - [${store.name}](store/types/${store.filename})";
    in
    concatStringsSep "\n" (map showEntry storesList) + "\n";

  "SUMMARY.md" = tableOfContents;

  storePages = listToAttrs (
    map (s: {
      name = s.filename;
      value = s.page;
    }) storesList
  );

in
storePages // { inherit "index.md" "SUMMARY.md"; }