about summary refs log tree commit diff
path: root/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-12-29T15·42+0100
committerVincent Ambo <tazjin@gmail.com>2017-12-29T15·42+0100
commit8703b6102c348d5e860af83a980ba5e1585e3964 (patch)
treee51d41d6da4411caab333f951ff12b34fedc25a7 /default.nix
parent5579ca7d6c620c5dd874ed0654d9a03a73fbf6d6 (diff)
feat(build): Add initial Nix-based build process
Adds a build script using ASDF's program-op to build an executable out
of the Gemma source code.

In addition a Nix derivation is provided that will both compile the
Elm source and place it in a folder, as well as create the executable.

Currently static file serving does not function as intended.
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/default.nix b/default.nix
new file mode 100644
index 000000000000..f4a10b542691
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,53 @@
+with import <nixpkgs> {};
+
+stdenv.mkDerivation rec {
+  name = "gemma";
+
+  src = ./.;
+
+  buildInputs = with lispPackages; [
+    sbcl
+    quicklisp
+    hunchentoot
+    cl-json
+    local-time
+    elmPackages.elm
+    pkgconfig
+  ];
+
+  # The build phase has three distinct things it needs to do:
+  #
+  # 1. "Compile" the Elm source into something useful to browsers.
+  #
+  # 2. Configure the Lisp part of the application to serve the compiled Elm
+  #
+  # 3. Build (and don't strip!) an executable out of the Lisp backend.
+  buildPhase = ''
+    mkdir -p $out/share/gemma $out/bin $src/build
+    mkdir .home && export HOME="$PWD/.home"
+
+    # Build Elm
+    cd frontend
+    elm-make --yes Main.elm --output $out/share/gemma/index.html
+
+    # Build Lisp
+    cd $src
+    quicklisp init
+    sbcl --load build.lisp
+
+    # ASDF writes this output into an extremely annoying path, but I also can't
+    # be bothered to figure out the output-translation definition for it.
+    mv $HOME/.cache/common-lisp/sbcl-*/$PWD/build/gemma $out/bin/gemma
+  '';
+
+  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;
+  };
+}