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
{ depot, pkgs, ... }:

let
  goDeps = import ../go-deps.nix { inherit depot pkgs; };

  unwrapped = depot.nix.buildGo.program {
    name = "source-forge";
    srcs = [
      ./main.go
      ./schema.go
      ./project.go
      ./meta.go
      ./ingest.go
      ./hook.go
      ./render.go
      ./serve.go
      ./page.go
    ];
    deps = [
      goDeps.modernc-sqlite
      # zombiezen wraps modernc.org/sqlite to expose SQLite's incremental blob I/O
      # (sqlite3_blob_open), used to stream git bundles and raw binary files
      # straight from the DB to the HTTP response without buffering them in RAM.
      goDeps.zombiezen-go-sqlite
      goDeps.alecthomas-chroma-v2
      goDeps.alecthomas-chroma-v2.formatters.html
      goDeps.alecthomas-chroma-v2.lexers
      goDeps.alecthomas-chroma-v2.styles
      goDeps.yuin-goldmark
      goDeps.yuin-goldmark.ast
      goDeps.yuin-goldmark.extension
      goDeps.yuin-goldmark.parser
      goDeps.yuin-goldmark.text
      goDeps.yuin-goldmark.util
      goDeps.yuin-goldmark-highlighting-v2
    ];
  };
in
pkgs.symlinkJoin {
  name = "source-forge";
  outputs = [ "out" "man" ];
  paths = [ unwrapped ];
  postBuild = ''
    mkdir -p $man/share/man/man1
    cp ${./source-forge.1} $man/share/man/man1/source-forge.1
  '';
}