From aee6d10404090d639b3bac1a1a8a644327a88575 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sun, 21 Apr 2024 13:17:26 -0500 Subject: [PATCH] shell.nix and default.nix work right now --- build.lisp | 32 +++++++++--------------------- default.nix | 54 +++++++-------------------------------------------- shell.nix | 2 ++ src/main.lisp | 19 +++++++++--------- tfcserver.asd | 5 +++++ 5 files changed, 32 insertions(+), 80 deletions(-) diff --git a/build.lisp b/build.lisp index bbf5102..dffa821 100644 --- a/build.lisp +++ b/build.lisp @@ -1,25 +1,11 @@ (load (sb-ext:posix-getenv "ASDF")) (asdf:load-asd (pathname (truename "tfcserver.asd"))) -(asdf:load-system "tfcserver") -(require "cffi") -(when (find-package :ql) (funcall (read-from-string "ql:quickload") :cffi)) -(when (find-package :ql) (funcall (read-from-string "ql:quickload") :deploy)) - -(defun pkg-config-add-lib (libname) - (let ((process (sb-ext:run-program "pkg-config" - (list libname "--libs-only-L") - :input t :output :stream :wait t))) - (let ((stream (sb-ext:process-output process))) - (loop for line = (read-line stream nil nil) - while line do - ;; Drop "-L" part, and add '/' to the end. '/' IS necessary! - (pushnew (pathname (concatenate 'string (subseq line 2) "/")) - cffi:*foreign-library-directories*)) - (sb-ext:process-close process)))) -;; Get libssl -(pkg-config-add-lib "libssl") - -(when (find-package :ql) (funcall (read-from-string "ql:quickload") :tfcserver)) -(push :deploy-console *features*) -(asdf:make :tfcserver) -(quit) +(asdf:load-system 'tfcserver) +;; (asdf:make :tfcserver) +;; (asdf:operate :program-op :tfcserver) +(asdf:disable-output-translations) +(sb-ext:save-lisp-and-die + #p"tfcserver" + :compression t + :toplevel #'tfcserver::main + :executable t) diff --git a/default.nix b/default.nix index c0a6e49..df3a2a7 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,6 @@ { stdenv, lib, - # hugo, - # go, - # cargo, - # rustc, - # clippy, - # rust-analyzer, - # rustfmt, pkg-config, gcc, gnumake, @@ -15,7 +8,6 @@ sbclPackages, makeWrapper, openssl, - # build-asdf-system, pkgs, ... }: @@ -31,79 +23,47 @@ let lass cl-smtp log4cl - cffi + buildapp pkgs.openssl pkgs.openssl.out pkgs.openssl.dev ]); in -stdenv.mkDerivation { - name = "tfcconnection"; +pkgs.sbcl.buildASDFSystem { pname = "tfcconnection"; version = "0.0.1"; src = ./.; - # cargoHash = "sha256-jtBw4ahSl88L0iuCXxQgZVm1EcboWRJMNtjxLVTtzts="; - # cargoLock = { - # lockFile = ./Cargo.lock; - # }; - nativeBuildInputs = [ gcc stdenv gnumake pkg-config makeWrapper - openssl - openssl.out - openssl.dev ]; - buildInputs = [ - # rustPlatform - # clippy - # rustfmt - openssl - openssl.out - openssl.dev + propagatedBuildInputs = [ + pkg-config sbcl' - ]; - - nativeLibs = [ openssl openssl.out openssl.dev ]; - # lispLibs = with sbclPackages; [ - # hunchentoot - # dexador - # jzon - # serapeum - # deploy - # spinneret - # lass - # cl-smtp - # log4cl - # ]; - - # ${cargo}/bin/cargo build buildPhase = '' export HOME=$(pwd) - ${sbcl'}/bin/sbcl --load build.lisp + make api ''; - # systems = "tfcserver"; - - # buildScript = ./build.lisp; - # cp target/debug/tfcapi $out/bin installPhase = '' mkdir -p $out/bin cp -v tfcserver $out/bin + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath [ sbcl' openssl.dev openssl.out openssl pkg-config ]}" wrapProgram $out/bin/tfcserver \ --prefix LD_LIBRARY_PATH : $LD_LIBRARY_PATH \ + --prefix SBCL_HOME : ${sbcl'}/lib/sbcl/sbcl.core \ ''; meta = with lib; { diff --git a/shell.nix b/shell.nix index d591c45..3b7793c 100644 --- a/shell.nix +++ b/shell.nix @@ -11,6 +11,7 @@ let lass cl-smtp log4cl + cl_plus_ssl pkgs.openssl pkgs.openssl.out pkgs.openssl.dev @@ -53,6 +54,7 @@ in mkShell rec { ]; shellHook = '' + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath nativeLibs}" alias hss='hugo server --noHTTPCache' ''; } diff --git a/src/main.lisp b/src/main.lisp index d693abc..b267b2a 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -1,13 +1,12 @@ -(require "hunchentoot") -(require "dexador") -;; (require "drakma") -(require "com.inuoe.jzon") -(require "serapeum") -(require "bordeaux-threads") -(require "spinneret") -(require "lass") -(require "cl-smtp") -(require "log4cl") +(asdf:load-system 'hunchentoot) +(asdf:load-system 'dexador) +(asdf:load-system 'com.inuoe.jzon) +(asdf:load-system 'serapeum) +(asdf:load-system 'bordeaux-threads) +(asdf:load-system 'spinneret) +(asdf:load-system 'lass) +(asdf:load-system 'cl-smtp) +(asdf:load-system 'log4cl) (defpackage tfcserver (:use :cl :com.inuoe.jzon :spinneret :serapeum)) diff --git a/tfcserver.asd b/tfcserver.asd index a22491b..203e0d6 100644 --- a/tfcserver.asd +++ b/tfcserver.asd @@ -1,5 +1,10 @@ #-asdf3.1 (error "requires asdf 3.1") ;; #+linux (deploy:define-library deploy::compression-lib :dont-deploy T) +#+sb-core-compression +(defmethod asdf:perform ((o asdf:image-op) (c asdf:system)) + (uiop:dump-image (asdf:output-file o c) + :executable t + :compression t)) (defsystem "tfcserver" :version "0.1.0"