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

# skalibs, execline, s6, s6-rc and s6-linux-init for the tolino: static musl
# binaries configured for prefix `/`, compiled with `zig cc`. See
# build/skarnet.go for why zig and why prefix `/`.
#
#   target  armv7 (Cortex-A7), for the device
#   host    x86_64, run at build time: s6-rc-compile compiles the service
#           database and s6-linux-init-maker writes /etc/s6-linux-init; both
#           emit references to /bin/..., which is what the device has.
let
  # In build order; each is configured against the ones before it.
  packages = [
    { name = "skalibs"; version = "2.15.0.0"; sha256 = "01w0gz4fh8b82hi141ygj5lcj9kpkhz8ha2kl69ia6dlmzl9dpkz"; }
    { name = "execline"; version = "2.9.9.1"; sha256 = "0spcqyv8azdlimx52d7q4sjqg1k69rxi35bi4vykcg59jwr56qxy"; }
    { name = "s6"; version = "2.15.0.0"; sha256 = "0k4yysb9xlpp7r85kpjizlbm2zq8hxcffxg06c0m91b2c8yzgpr7"; }
    { name = "s6-rc"; version = "0.6.1.1"; sha256 = "0ba0hrm60gkkdqsvz7g6cjy75w1pjk1s9wcb49mfa7my6mm24kxm"; }
    { name = "s6-linux-init"; version = "1.2.0.1"; sha256 = "0z3xbkn974iw0ahrzbr1c10r6cp7czj6na4svzvr04rxd09rpmbj"; }
  ];
  srcs = map
    (p: pkgs.fetchurl {
      url = "https://skarnet.org/software/${p.name}/${p.name}-${p.version}.tar.gz";
      inherit (p) sha256;
    })
    packages;

  build = name: { target, cpu ? "" }:
    depot.nix.runGoCommand name ./build/skarnet.go {
      inherit srcs target cpu;
      inherit (pkgs) zig gnutar gzip gnumake;
      sh = "${pkgs.bash}/bin/sh";
      # configure and the Makefiles use these standard tools by name.
      toolPath = lib.makeBinPath [ pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.gawk pkgs.findutils pkgs.bash pkgs.gnumake ];
    };
in
{
  target = build "skarnet-armv7l-musl-static" {
    target = "arm-linux-musleabihf";
    cpu = "cortex_a7";
  };
  host = build "skarnet-host-musl-static" {
    target = "x86_64-linux-musl";
  };
}