diff options
-rw-r--r-- | nix/buildLisp/default.nix | 24 | ||||
-rw-r--r-- | nix/buildLisp/example/main.lisp | 2 |
2 files changed, 10 insertions, 16 deletions
diff --git a/nix/buildLisp/default.nix b/nix/buildLisp/default.nix index 15dc5f73e4ba..66de38663108 100644 --- a/nix/buildLisp/default.nix +++ b/nix/buildLisp/default.nix @@ -9,7 +9,7 @@ let inherit (builtins) map elemAt match; - inherit (pkgs.third_party) lib runCommandNoCC writeText writeShellScriptBin sbcl; + inherit (pkgs.third_party) lib runCommandNoCC makeWrapper writeText writeShellScriptBin sbcl; # # Internal helper definitions @@ -77,15 +77,6 @@ let lib.flatten (native ++ (map (d: d.lispNativeDeps) deps)) ); - # 'pushLibDirs' generates forms that push all native library paths - # onto the variable `CFFI:*FOREIGN-LIBRARY-DIRECTORIES*` which is - # required for any runtime loading of libraries via CFFI. - pushLibDirs = deps: lib.concatStringsSep "\n" ( - map (l: "(push \"${ - lib.getLib l - }/lib\" cffi:*foreign-library-directories*)") (allNative [] deps) - ); - # 'genDumpLisp' generates a Lisp file that instructs SBCL to dump # the currently loaded image as an executable to $out/bin/$name. # @@ -96,10 +87,6 @@ let ${genLoadLisp deps} - ;; Push library directories if CFFI is in use. - (when (boundp 'cffi:*foreign-library-directories*) - ${pushLibDirs deps}) - (let* ((bindir (concatenate 'string (sb-posix:getenv "out") "/bin")) (outpath (make-pathname :name "${name}" :directory bindir))) @@ -150,15 +137,22 @@ let program = { name, main ? "${name}:main", srcs, deps ? [], native ? [] }: let lispDeps = allDeps deps; + libPath = lib.makeLibraryPath (allNative native lispDeps); selfLib = library { inherit name srcs native; deps = lispDeps; }; - in runCommandNoCC "${name}" {} '' + in runCommandNoCC "${name}" { + nativeBuildInputs = [ makeWrapper ]; + LD_LIBRARY_PATH = libPath; + } '' mkdir -p $out/bin + ${sbcl}/bin/sbcl --script ${ genDumpLisp name main ([ selfLib ] ++ lispDeps) } + + wrapProgram $out/bin/${name} --prefix LD_LIBRARY_PATH : "${libPath}" ''; # 'sbclWith' creates an image with the specified libraries / diff --git a/nix/buildLisp/example/main.lisp b/nix/buildLisp/example/main.lisp index f98bb8409a61..a29390cf4dba 100644 --- a/nix/buildLisp/example/main.lisp +++ b/nix/buildLisp/example/main.lisp @@ -4,4 +4,4 @@ (in-package :example) (defun main () - (format t "i <3 ~S" (who))) + (format t "i <3 ~A~%" (who))) |