about summary refs log tree commit diff
path: root/services/gemma/default.nix
blob: 409d8eef381a09c18bd210ec16618d7b704e6d03 (plain) (blame)
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
{ stdenv, sbcl, lispPackages, elmPackages, makeWrapper, openssl }:

let frontend = stdenv.mkDerivation {
  name = "gemma-frontend";
  src = ./frontend;
  buildInputs = [ elmPackages.elm ];

  phases = [ "unpackPhase" "buildPhase" ];
  buildPhase = ''
    mkdir .home && export HOME="$PWD/.home"
    mkdir -p $out
    elm-make --yes Main.elm --output $out/index.html
  '';
};
in stdenv.mkDerivation rec {
  name = "gemma";
  src = ./.;

  nativeBuildInputs = with lispPackages; [
    sbcl
    hunchentoot
    cl-json
    cffi
    cl-prevalence
    local-time
    makeWrapper
  ];

  buildPhase = ''
    mkdir -p $out/share/gemma $out/bin

    # Build Lisp using the Nix-provided wrapper which sets the load
    # paths correctly.
    cd $src
    env GEMMA_BIN_TARGET=$out/bin/gemma common-lisp.sh --load build.lisp

    # Wrap gemma to find OpenSSL at runtime:
    wrapProgram $out/bin/gemma --prefix LD_LIBRARY_PATH : "${openssl.out}/lib"

    # and finally copy the frontend to the appropriate spot
    cp ${frontend}/index.html $out/share/gemma/index.html
  '';

  installPhase = "true";

  # Stripping an SBCL executable removes the application, which is unfortunate.
  dontStrip = true;

  meta = with stdenv.lib; {
    description = "Tool for tracking recurring tasks";
    homepage    = "https://github.com/tazjin/gemma";
    license     = licenses.gpl3;

    # Lisp builds are broken for some reason (2019-09-22)
    broken = true;
  };
}