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
54
55
56
57
58
59
60
61
62
63
{ depot, pkgs, lib, ... }:

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

  unwrapped = depot.nix.buildGo.program {
    name = "observations-inbox";
    srcs = [
      ./main.go
      ./schema.go
      ./store.go
      ./submit.go
      ./review.go
      ./probe.go
      ./notify.go
      ./transcribe.go
    ];
    deps = [
      goDeps.modernc-sqlite
    ];
  };

in
pkgs.symlinkJoin {
  name = "observations-inbox";
  outputs = [ "out" "man" ];
  paths = [ unwrapped ];
  buildInputs = [ pkgs.makeWrapper ];

  postBuild = ''
    mkdir -p $man/share/man/man1
    cp ${./observations-inbox.1} $man/share/man/man1/observations-inbox.1

    # ffprobe reads how long a recording is, and ffmpeg rewrites the container
    # of one that does not say — a recording made in the browser, which cannot
    # know its own length while it is being written.
    #
    # In the closure rather than expected on PATH so that a submission is
    # measured wherever this is installed, instead of only where ffmpeg
    # happens to be. Neither is required: without them a submission is stored
    # and served exactly as before, with an unknown length.
    wrapProgram $out/bin/observations-inbox \
      --prefix PATH : ${lib.makeBinPath [ pkgs.ffmpeg-headless ]}
  '';

  meta = {
    description = "Accept audio replies to observations episodes";
    longDescription = ''
      The endpoint behind the drop zone on the observations website. A
      listener drops a recording, it is stored in one SQLite file, and a
      notification carrying an unguessable link arrives by mail.

      There is no account, no listing route, and no way to get from one
      submission to another: the mail is the only record that a submission
      exists. Uploads are capped at 5 MB each and 50 MB in total, gated behind
      a passphrase spoken at the start of each episode, and accepted only if
      the bytes really are audio.

      See observations-inbox(1) for the reference and observations(7) for why
      the format has an inbox at all.
    '';
  };
}