{ depot, pkgs, lib, ... }: let bins = depot.nix.getBins pkgs.lowdown [ "lowdown" ] // depot.nix.getBins pkgs.cdb [ "cdbget" "cdbmake" "cdbdump" ] // depot.nix.getBins pkgs.coreutils [ "mv" "cat" "printf" "test" ] // depot.nix.getBins pkgs.s6-networking [ "s6-tcpserver" ] // depot.nix.getBins pkgs.time [ "time" ] ; # / toplevel = [ { route = [ "notes" ]; name = "Notes"; page = router; } ]; # /notes/* notes = [ { route = [ "notes" "preventing-oom" ]; name = "Preventing OOM"; page = renderNote "preventing-oom" ./notes/preventing-oom.md; } { route = [ "notes" "rust-string-conversions" ]; name = "Converting between different String types in Rust"; page = renderNote "rust-string-conversions" ./notes/rust-string-conversions.md; } ]; # convert a note to html via lowdown renderNote = name: note: depot.nix.runExecline "${name}.html" {} [ "importas" "out" "out" bins.lowdown "-s" "-Thtml" "-o" "$out" note ]; # all notes with `route` converted to an absolute path notesFullRoute = lib.pipe notes [ (map (x@{route, ...}: x // { route = mkRoute route; })) ]; # a cdb from route to a netencoded version of data for each route router = lib.pipe notesFullRoute [ (map (x: { name = x.route; value = depot.users.Profpatsch.netencode.gen.dwim x; })) lib.listToAttrs (cdbMake "notes-router") ]; # look up a route by path ($1) router-lookup = depot.nix.writeExecline "router-lookup" { readNArgs = 1; } [ cdbLookup router "$1" ]; runExeclineStdout = name: args: cmd: depot.nix.runExecline name args ([ "importas" "-ui" "out" "out" "redirfd" "-w" "1" "$out" ] ++ cmd); index = runExeclineStdout "index" { stdin = depot.users.Profpatsch.netencode.gen.dwim notesFullRoute; } [ "withstdinas" "-in" "TEMPLATE_DATA" "pipeline" [ bins.printf ''