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")) (load (sb-ext:posix-getenv "ASDF"))
(asdf:load-asd (pathname (truename "tfcserver.asd"))) (asdf:load-asd (pathname (truename "tfcserver.asd")))
(asdf:load-system "tfcserver") (asdf:load-system 'tfcserver)
(require "cffi") ;; (asdf:make :tfcserver)
(when (find-package :ql) (funcall (read-from-string "ql:quickload") :cffi)) ;; (asdf:operate :program-op :tfcserver)
(when (find-package :ql) (funcall (read-from-string "ql:quickload") :deploy)) (asdf:disable-output-translations)
(sb-ext:save-lisp-and-die
(defun pkg-config-add-lib (libname) #p"tfcserver"
(let ((process (sb-ext:run-program "pkg-config" :compression t
(list libname "--libs-only-L") :toplevel #'tfcserver::main
:input t :output :stream :wait t))) :executable 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)

View file

@ -1,13 +1,6 @@
{ {
stdenv, stdenv,
lib, lib,
# hugo,
# go,
# cargo,
# rustc,
# clippy,
# rust-analyzer,
# rustfmt,
pkg-config, pkg-config,
gcc, gcc,
gnumake, gnumake,
@ -15,7 +8,6 @@
sbclPackages, sbclPackages,
makeWrapper, makeWrapper,
openssl, openssl,
# build-asdf-system,
pkgs, pkgs,
... ...
}: }:
@ -31,79 +23,47 @@ let
lass lass
cl-smtp cl-smtp
log4cl log4cl
cffi buildapp
pkgs.openssl pkgs.openssl
pkgs.openssl.out pkgs.openssl.out
pkgs.openssl.dev pkgs.openssl.dev
]); ]);
in in
stdenv.mkDerivation { pkgs.sbcl.buildASDFSystem {
name = "tfcconnection";
pname = "tfcconnection"; pname = "tfcconnection";
version = "0.0.1"; version = "0.0.1";
src = ./.; src = ./.;
# cargoHash = "sha256-jtBw4ahSl88L0iuCXxQgZVm1EcboWRJMNtjxLVTtzts=";
# cargoLock = {
# lockFile = ./Cargo.lock;
# };
nativeBuildInputs = [ nativeBuildInputs = [
gcc gcc
stdenv stdenv
gnumake gnumake
pkg-config pkg-config
makeWrapper makeWrapper
openssl
openssl.out
openssl.dev
]; ];
buildInputs = [ propagatedBuildInputs = [
# rustPlatform pkg-config
# clippy
# rustfmt
openssl
openssl.out
openssl.dev
sbcl' sbcl'
];
nativeLibs = [
openssl openssl
openssl.out openssl.out
openssl.dev openssl.dev
]; ];
# lispLibs = with sbclPackages; [
# hunchentoot
# dexador
# jzon
# serapeum
# deploy
# spinneret
# lass
# cl-smtp
# log4cl
# ];
# ${cargo}/bin/cargo build
buildPhase = '' buildPhase = ''
export HOME=$(pwd) export HOME=$(pwd)
${sbcl'}/bin/sbcl --load build.lisp make api
''; '';
# systems = "tfcserver";
# buildScript = ./build.lisp;
# cp target/debug/tfcapi $out/bin # cp target/debug/tfcapi $out/bin
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
cp -v tfcserver $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 \ wrapProgram $out/bin/tfcserver \
--prefix LD_LIBRARY_PATH : $LD_LIBRARY_PATH \ --prefix LD_LIBRARY_PATH : $LD_LIBRARY_PATH \
--prefix SBCL_HOME : ${sbcl'}/lib/sbcl/sbcl.core \
''; '';
meta = with lib; { meta = with lib; {

View file

@ -11,6 +11,7 @@ let
lass lass
cl-smtp cl-smtp
log4cl log4cl
cl_plus_ssl
pkgs.openssl pkgs.openssl
pkgs.openssl.out pkgs.openssl.out
pkgs.openssl.dev pkgs.openssl.dev
@ -53,6 +54,7 @@ in mkShell rec {
]; ];
shellHook = '' shellHook = ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath nativeLibs}"
alias hss='hugo server --noHTTPCache' alias hss='hugo server --noHTTPCache'
''; '';
} }

View file

@ -1,13 +1,12 @@
(require "hunchentoot") (asdf:load-system 'hunchentoot)
(require "dexador") (asdf:load-system 'dexador)
;; (require "drakma") (asdf:load-system 'com.inuoe.jzon)
(require "com.inuoe.jzon") (asdf:load-system 'serapeum)
(require "serapeum") (asdf:load-system 'bordeaux-threads)
(require "bordeaux-threads") (asdf:load-system 'spinneret)
(require "spinneret") (asdf:load-system 'lass)
(require "lass") (asdf:load-system 'cl-smtp)
(require "cl-smtp") (asdf:load-system 'log4cl)
(require "log4cl")
(defpackage tfcserver (defpackage tfcserver
(:use :cl :com.inuoe.jzon :spinneret :serapeum)) (:use :cl :com.inuoe.jzon :spinneret :serapeum))

View file

@ -1,5 +1,10 @@
#-asdf3.1 (error "requires asdf 3.1") #-asdf3.1 (error "requires asdf 3.1")
;; #+linux (deploy:define-library deploy::compression-lib :dont-deploy T) ;; #+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" (defsystem "tfcserver"
:version "0.1.0" :version "0.1.0"