shell.nix and default.nix work right now

This commit is contained in:
Chris Cochrun 2024-04-21 13:17:26 -05:00
parent 54dab680d6
commit aee6d10404
5 changed files with 32 additions and 80 deletions

View file

@ -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)

View file

@ -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; {

View file

@ -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'
'';
}

View file

@ -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))

View file

@ -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"