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
# The rss-kakapo server, as a plain callPackage function, so that a consumer
# can build it against its own nixpkgs:
#
#   pkgs.callPackage "${rss-kakapo-src}/package.nix" { src = rss-kakapo-src; }
#
# flake.nix does exactly this with the flake's own nixpkgs.
#
# Produces the server binary (bin/rss-kakapo), which carries its web templates
# and assets compiled in, so it runs from any directory. The manpage,
# rss-kakapo(1), is in the man output.
{ lib, buildGoModule, installShellFiles, src }:

let
  # Bump the suffix for every fork release; the base is the upstream
  # RSS Parrot tag the fork sits on.
  version = "0.0.99-kakapo.4";
in
buildGoModule {
  pname = "rss-kakapo";
  inherit version src;
  # Only the server; cmd/feed-survey is a research tool, run with go run.
  subPackages = [ "." ];
  vendorHash = "sha256-i9nI3wH5cQ8oTxNt5nd8octCLpCBbm+ML6zcNEBUfGo=";
  # modernc.org/sqlite is pure Go; no C toolchain needed.
  env.CGO_ENABLED = "0";

  # Shown in the web footer and sent in the User-Agent header; compiled into
  # the binary along with the rest of www/.
  postPatch = ''
    echo "v${version}" > www/version.txt
  '';

  # go install names the binary after the last element of the module path,
  # which is rss-kakapo, so bin/rss-kakapo needs no renaming here.
  postInstall = ''
    installManPage ${src}/rss-kakapo.1
  '';

  nativeBuildInputs = [ installShellFiles ];
  outputs = [ "out" "man" ];

  meta = {
    description = "Turn Mastodon into your feed reader (a fork of RSS Parrot)";
    homepage = "https://sources.profpatsch.de/rss-kakapo/";
    license = lib.licenses.mit;
    mainProgram = "rss-kakapo";
  };
}