about summary refs log tree commit diff
path: root/services/gemma/build.lisp
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-06-29T13·13+0100
committerVincent Ambo <tazjin@google.com>2019-06-29T13·13+0100
commit60532a541b4a1e2c19bb9de95f1ffd72d1579067 (patch)
treeb8cbdf87bc5cf8d3e27835f034aa14d7c44a286f /services/gemma/build.lisp
parent61be253d6baa99f0a2208425b8a03b444bb1b184 (diff)
refactor(gemma): Move Gemma source into monorepo stucture
Diffstat (limited to 'services/gemma/build.lisp')
-rw-r--r--services/gemma/build.lisp31
1 files changed, 31 insertions, 0 deletions
diff --git a/services/gemma/build.lisp b/services/gemma/build.lisp
new file mode 100644
index 000000000000..ce67a91f6585
--- /dev/null
+++ b/services/gemma/build.lisp
@@ -0,0 +1,31 @@
+;; 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")
+
+(asdf:operate 'asdf:program-op :gemma)