aboutsummaryrefslogtreecommitdiffhomepage
path: root/package.nix
blob: 3423e9fab2d9824dbf048f9cffb72df9a7034c1b (plain)
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
64
65
66
67
68
69
70
71
# package.nix - spine derivation (build logic)
#
# Standalone, callPackage-style derivation for the spine binary. Used by
# shell.nix to put a freshly-built spine on PATH inside the dev shell.
# May also be consumed via:
#   nix-build ./package.nix
#   pkgs.callPackage ./package.nix {}
#
# Compiler defaults to ldc/ldmd2 (matching the flake's default package
# `spine-nixpkgs-ldc`). Override to build with dmd:
#   pkgs.callPackage ./package.nix {
#     compilerPkg = pkgs.dmd;
#     compilerBin = "dmd";
#     buildType   = "dmd";
#   }
{
  lib,
  stdenv,
  dub,
  ldc,
  gnumake,
  sqlite,
  compilerPkg ? ldc,
  compilerBin ? "ldmd2",
  buildType   ? "ldmd2",
  rev         ? "unknown",
}:
stdenv.mkDerivation {
  pname   = "spine";
  version = "0.21.0";
  src     = lib.cleanSource ./.;
  buildInputs       = [ sqlite ];
  nativeBuildInputs = [ dub compilerPkg gnumake ];
  preBuild = ''
    export HOME=$TMPDIR
  '';
  buildPhase = ''
    runHook preBuild
    buildCMD="dub run --cache=local \
      --compiler=$(type -P ${compilerBin}) \
      --build=${buildType} \
      --combined --skip-registry=all"
    echo $buildCMD
    $buildCMD
    runHook postBuild
  '';
  checkPhase = ''
    runHook preCheck
    dub test --combined --skip-registry=all
    runHook postCheck
  '';
  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin
    install -m755 ./bin/spine $out/bin/spine
    runHook postInstall
  '';
  postInstall = ''
    echo `ls -la $out/bin/spine`
    echo "❯❯ spine-v0.21.0 (rev: ${rev})"
    $out/bin/spine -v
  '';
  meta = {
    description     = "A sisu like parser & document generator";
    longDescription = "a sisu like parser & document generator";
    homepage        = "https://sisudoc.org";
    license         = lib.licenses.agpl3Plus;
    platforms       = lib.platforms.linux;
    mainProgram     = "spine";
  };
}