How to use quicklisp with sbcl?

One of the solutions I was recommended (in telegram ru NixOS chat):

  1. Install quicklisp as per https://www.quicklisp.org/beta/#installation
    as “dirty” part of the system
  2. For the projects, use nix-shell
    with lisp compiler (sbcl or another) and any non-lisp dependencies specified in nix
  3. Lisp compiler would not automatically see dependencies from nix-shell builtinputs,
    so in shell definition setting explicitly LD_LIBRARY_PATH and sometimes CPATH for headers would be required

How to get external libraries, on example of loading CLOG

(ql:quickload :clog)
failed with error

0: (CFFI::FL-ERROR “Unable to load any of the alternatives:~% ~S” (“libcrypto.so.1.1” “libcrypto.so.1.0.0” “libcrypto.so.3” “libcrypto.so”))
1: (CFFI::TRY-FOREIGN-LIBRARY-ALTERNATIVES CL+SSL/CONFIG::LIBCRYPTO (“libcrypto.so.1.1” “libcrypto.so.1.0.0” “libcrypto.so.3” “libcrypto.so”) NIL)

I made shell

          devShells.default = pkgs.mkShell {
            buildInputs = [
              pkgs.sbcl

              # for koans
              pkgs.inotify-tools

              # for CLOG
              pkgs.openssl
              pkgs.sqlite
            ];
            shellHook = ''
              export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath([pkgs.openssl])}:${pkgs.lib.makeLibraryPath([pkgs.sqlite])}
            '';
          };

(and adding them to buildInputs is probably not even required?)

Then with direnv picking up new env vars, and sbcl restarted
(ql:quickload :clog) finished without errors

As I understand this advice Tip for SBCL, Quicklisp, and Library Dependencies with pkg-config it’s written to pick up dependencies that are installed system-wide through nix, not a separate shell

Other solution mentioned without too many details is that there’s also possibilty of using pkgs.lispPackages_new

2 Likes