about summary refs log tree commit diff
path: root/build.lisp
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 /build.lisp
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 'build.lisp')
-rw-r--r--build.lisp37
1 files changed, 37 insertions, 0 deletions
diff --git a/build.lisp b/build.lisp
new file mode 100644
index 0000000000..3c8ce33721
--- /dev/null
+++ b/build.lisp
@@ -0,0 +1,37 @@
+;; Build script for use within Nix.
+
+(require :asdf)
+(require :sb-posix)
+(require :cffi)
+
+(push (format nil "~A/" (sb-posix:getcwd)) asdf:*central-registry*)
+
+;; Quicklisp is configured in the Nix build script
+(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
+                                       (user-homedir-pathname))))
+  (when (probe-file quicklisp-init)
+    (load quicklisp-init)))
+
+;; OpenSSL linking requires pkg_config on NixOS.
+(ql:quickload "inferior-shell")
+
+(defun pkg-config-lib-path (lib)
+  "Look up the location of a library using pkg-config."
+  (let ((flag (inferior-shell:run `("pkg-config" "--libs-only-L" ,lib)
+                                  :output '(:string :stripped t))))
+    (concatenate 'string (subseq flag 2) "/")))
+
+(pushnew (pathname (pkg-config-lib-path "openssl"))
+         cffi:*foreign-library-directories*
+         :test #'equal)
+
+;; cl-prevalence is not in the current Quicklisp -> Nix snapshot
+(ql:quickload "cl-prevalence")
+
+;; the $out path should be set in the application to let Hunchentoot serve the
+;; correct static files.
+
+(if (sb-posix:getenv "out")
+    (defvar *gemma-nix-out-dir* (sb-posix:getenv "out")))
+
+(asdf:operate 'asdf:program-op :gemma)