chriswarbo-net: c88487449c2908dc426688a693d737f839767659
1: { dirsToAttrs, isPath, lib, render }:
2:
3: with rec {
4: inherit (builtins) isAttrs toJSON;
5: inherit (lib)
6: concatStringsSep hasSuffix isDerivation mapAttrs' removeSuffix take;
7:
8: mdToHtml = n: if hasSuffix ".md" n then "${removeSuffix ".md" n}.html" else n;
9:
10: renderGo = prefix: n: v: rec {
11: name = mdToHtml n;
12: # Standalone files should be passed to render
13: value = if isDerivation v || isPath v then
14: render {
15: inherit name;
16: # We'll skip tests for anything in the "unfinished" directory
17: unfinished = take 1 prefix == [ "unfinished" ];
18: file = v;
19: SOURCE_PATH = concatStringsSep "/" (prefix ++ [ n ]);
20: TO_ROOT = concatStringsSep "/" ([ "." ] ++ map (_: "..") prefix);
21: }
22: else if isAttrs v then # Directories will become attrsets
23: (if v ? "default.nix" then # defer to a default.nix file if present
24: import v."default.nix" { }
25: else # Otherwise recurse
26: go (prefix ++ [ n ]) v)
27: else
28: abort "Can't render ${toJSON { inherit n v; }}";
29: };
30:
31: go = prefix: mapAttrs' (renderGo prefix);
32: };
33:
34: dir:
35: go [ dir ] (dirsToAttrs (../.. + "/${dir}"))
Generated by git2html.