How to use quicklisp with sbcl?

Installed sbcl with
home.packages = [ pkgs.sbcl ];
that works well with sly repl for finishing the textbook.

Next I want to learn to load different packages, quicklisp seems to be the way to go about loading things into repl, and possibly projects.

In the NixOS search found only package for quicklisp, not options, and also there are no options in home-manager.

adding home.packages = [ pkgs.lispPackages.quicklisp ];
makes binary available on “~/.nix-profile/bin/quicklisp”
and library available on “.nix-profile/lib/common-lisp/quicklisp/setup.lisp”

Article on installing quicklisp Quicklisp beta ( Loading After Installation )
seems to say that I need to evaluate
(load "~/.nix-profile/lib/common-lisp/quicklisp/setup.lisp")
to make quicklisp available to current session

But that results in an error
“Can’t create directory /nix/store/fglfv7x2zbvg3crn6ss28w9yzl9n7ysd-lisp-quicklisp-2021-02-13/lib/common-lisp/quicklisp/dists”

It seems that maybe I need to add quicklisp to startup config for sbcl, that’s installed into nix store?

I’m unsure how to proceed, and whether it’s possible to use quicklisp from nix for “non-purely” loading packages from web.
Maybe this binary is only meant for use with quicklisp packages which are wrapped into nix, and are installed from pkgs.quicklispPackagesClisp?

I tried to look for wiki page, or manual page, and in README in nixpkgs module

For now only way I see is installing quicklisp outside of nix, through downloadable installer

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

  1. Install quicklisp as per Quicklisp beta
    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” (“” “” “” “”))

I made shell

          devShells.default = pkgs.mkShell {
            buildInputs = [

              # for koans

              # for CLOG
            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

1 Like