Friends are like snow, they disappear when you pee on them.

External Content not shown. Further Information.

Unfortunately, Common LISP support in NixOS is worse than one would expect (and unfortunately I do not have the time to change this) – nothing comparable to the common-lisp-controller, as far as I see. In NixOS, I do not want to install sbcl globally when I don't need it for anything else but developing my lisp projects, which is something that should be done inside a nix-shell.

As probably many lispers, I like getting my packages through QuickLisp. According to the FAQ, it is possible to install packages into other directories, so it would be possible – in theory – to have different nix-shells with a different quicklisp package directory; but then, I would probably install the same software multiple times, and the compile-cache would not work as desired. The directory structure of QuickLisp looks like it should be possible to have different branches, but I do not know of such a mechanism, and for my use case, one QuickLisp directory is sufficient. It would, though, be nice to have something like Cabal2Nix for QuickLisp.

Anyway, for my use case, I need SLIME and the CFFI, and some other packages. One of my Nix expressions, for example, is

with import <nixpkgs> {};
runCommand "bash"
{
  buildInputs = [rlwrap stdenv bash emacs php sbcl imagemagick gnome3.eog git geoip libressl lispPackages.cffi emacs24PackagesNg.markdown-mode];
} ""

The problem is that the CFFI appears not to follow the Nix environment when loading dynamic libraries. However, the variable $NIX_LISP_LD_LIBRARY_PATH is set automatically, and it is sufficient to append it to the $LD_LIBRARY_PATH.

$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NIX_LISP_LD_LIBRARY_PATH rlwrap sbcl

Now, through my global installation of QuickLisp, I can install swank. In the QuickLisp directory, there will be the files for SLIME. My custom emacs configuration, which I save in a file emacsconfig.el in this nix-shell's directory (where the default.nix is stored), looks like

(add-to-list 'load-path "~/quicklisp/dists/quicklisp/software/slime-2.14")
(require 'slime-autoloads)
(setq inferior-lisp-program "sbcl")
(add-to-list 'slime-contribs 'slime-fancy)

Now I can run

$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NIX_LISP_LD_LIBRARY_PATH emacs -q -l emacsconfig.el

and start SLIME as usual via M-x slime.