3 This page documents the Nix API of nix-cl.
7 The core API functions are `build-asdf-system` and
8 `lispWithPackagesInternal`.
10 They are considered more low-level that the rest of the API, which
11 builds on top of them to provide a more convenient interface with sane
14 The higher-level API provides a lot of pre-configured packages,
15 including all of Quicklisp, and consists of the functions:
20 Finally, there are functions that provide pre-defined Lisps, for
21 people who don't need to customize that:
23 - `abclPackages`, `eclPackages`, `cclPackages`, `claspPackages`, `sbclPackages`
24 - `abclWithPackages`, `eclWithPackages`, `cclWithPackages`, `claspWithPackages`, `sbclWithPackages`
26 The following is an attempt to document all of this.
28 ## Packaging systems - `build-asdf-system`
30 Packages are declared using `build-asdf-system`. This function takes
31 the following arguments and returns a `derivation`.
33 #### Required arguments
36 Name of the package/library
39 Version of the package/library
42 Source of the package/library (`fetchzip`, `fetchgit`, `fetchhg` etc.)
45 This command must load the provided file (`$buildScript`) then exit
46 immediately. For example, SBCL's --script flag does just that.
48 #### Optional arguments
52 Patches to apply to the source code before compiling it. This is a
55 ##### `nativeLibs ? []`
57 Native libraries, will be appended to the library
58 path. (`pkgs.openssl` etc.)
62 Java libraries for ABCL, will be appended to the class path.
66 Lisp dependencies These must themselves be packages built with
69 ##### `systems ? [ pname ]`
71 Some libraries have multiple systems under one project, for example,
72 [cffi] has `cffi-grovel`, `cffi-toolchain` etc. By default, only the
73 `pname` system is build.
75 `.asd's` not listed in `systems` are removed before saving the library
76 to the Nix store. This prevents ASDF from referring to uncompiled
79 Also useful when the `pname` is different than the system name, such
80 as when using [reverse domain naming]. (see `jzon` ->
83 [cffi]: https://cffi.common-lisp.dev/
84 [reverse domain naming]: https://en.wikipedia.org/wiki/Reverse_domain_name_notation
86 ##### `asds ? systems`
88 The .asd files that this package provides. By default, same as
93 A `derivation` that, when built, contains the sources and pre-compiled
94 FASL files (Lisp implementation dependent) alongside any other
95 artifacts generated during compilation.
99 [bordeaux-threads.nix] contains a simple example of packaging
100 `alexandria` and `bordeaux-threads`.
102 [bordeaux-threads.nix]: /examples/bordeaux-threads.nix
104 ## Building a Lisp with packages: `lispWithPackagesInternal`
106 Generators of Lisps configured to be able to `asdf:load-system`
107 pre-compiled libraries on run-time are built with
108 `lispWithPackagesInternal`.
110 #### Required Arguments
114 An attribute set of `derivation`s returned by `build-asdf-system`
118 `lispWithPackagesInternal` returns a function that takes one argument:
119 a function `(lambda (clpkgs) packages)`, that, given a set of
120 packages, returns a list of package `derivation`s to be included in
125 The [sbcl-with-bt.nix] example creates a runnable Lisp where the
126 `bordeaux-threads` defined in the previous section is precompiled and
127 loadable via `asdf:load-system`:
129 [sbcl-with-bt.nix]: /examples/sbcl-with-bt.nix
131 ## Reusing pre-packaged Lisp libraries: `lispPackagesFor`
133 `lispPackagesFor` is a higher level version of
134 `lispPackagesForInternal`: it only takes one argument - a Lisp command
135 to use for compiling packages. It then provides a bunch of ready to
138 #### Required Arguments
142 The Lisp command to use in calls to `build-asdf-system` while building
143 the library-provided Lisp package declarations.
147 A set of packages built with `build-asdf-system`.
151 The [abcl-package-set.nix] example generates a set of thousands of packages for ABCL.
153 [abcl-package-set.nix]: /examples/abcl-package-set.nix
155 ## Reusing pre-packaged Lisp libraries, part 2: `lispWithPackages`
157 This is simply a helper function to avoid having to call
158 `lispPackagesFor` if all you want is a Lisp-with-packages wrapper.
160 #### Required Arguments
164 The Lisp command to pass to `lispPackagesFor` in order for it to
165 generate a package set. That set is then passed to
166 `lispWithPackagesInternal`.
170 A Lisp-with-packages function (see sections above).
174 The [abcl-with-packages.nix] example creates an `abclWithPackages` function.
176 [abcl-with-packages.nix]: /examples/abcl-with-packages.nix
178 ## Using the default Lisp implementations
180 This is the easiest way to get going with `nix-cl` in general. Choose
181 the CL implementation of interest and a set of libraries, and get a
182 lisp-with-packages wrapper with those libraries pre-compiled.
184 #### `abclPackages`, `eclPackages`, `cclPackages`, `claspPackages`, `sbclPackages`
186 Ready to use package sets.
188 #### `abclWithPackages`, `eclWithPackages`, `cclWithPackages`, `claspWithPackages`, `sbclWithPackages`
190 Ready to use wrapper generators.
194 For example, to open a shell with SBCL + hunchentoot + sqlite in PATH:
196 nix-shell -p 'with import ./. {}; sbclWithPackages (ps: [ ps.hunchentoot ps.sqlite ])'