Announcing swipl-nix

Hello prolog friends!

Today I would like to announce swipl-nix, a project for building and running different versions of SWI-Prolog using the Nix package manager.

Nix?

Nix is a source-based package manager that aims to provide deterministic builds. This allows you to take a program packaged by Nix and compile and run it on any machine with Nix installed, without having to worry about installing dependencies.

Using swipl-nix, you can build code that requires a particular version of SWI-Prolog and be sure that on deployment, the same version of SWI-Prolog will be used. You can even customize the packaging to apply your own patchlist, enable extra configuration flags, or have a particular set of packages pre-installed.

What swipl-nix actually is

swipl-nix itself is a bit of automation that figures out all the version tags from the swipl and swipl-devel repositories, precomputes a bunch of hashes, then combines this with the SWI-Prolog packaging that is already present in nixpkgs to provide a package set of each version of SWI-Prolog since 8.4.0.

This is provided as a flake or as an overlay, which means that others can depend on swipl-nix from their own nix projects, or run the provided packages, without needing to directly check out or interact with the swipl-nix repository.

Future work

I really like this Nix thing and see a lot of applications for SWI-Prolog, so I’ll probably be working in this ecosystem a bit more. Roughly, my plans are as follows.

Improve nixpkgs packaging

I’ll be working on improving the packaging in nixpkgs to have its options more closely match the various ways SWI-Prolog can be built. I would also like to push the supported versions back a bit further, since 8.4.0 is still pretty new.

Write a proper Nix application builder for SWI-Prolog

nixpkgs has wrappers for many languages or environments to quickly produce binaries. Since SWI-Prolog has an imaging feature, providing such a feature of our own should be viable.

Automate the version refresh

swipl-nix now requires a manual refresh any time the tag set is changed. I want to make this be an automatic refresh that happens every night, probably using some github action.
With a bit of help from the swipl and swipl-devel repositories, we could even make this so that tag additions there trigger the refresh.

Move to the SWI-Prolog organization?

I’m now hosting swipl-nix under my own username on github, but it might make sense to host this under the SWI-Prolog organization instead.
This is an open question. I don’t know if the current governance structure of SWI-Prolog allows for that. But it would be good if this was in a project domain where more people from the community have the ability to directly contribute.

Final thoughts

Please give swipl-nix a try and let me know if you run into any issues! Also, if you have any thoughts about any of the future work or direction I describe above, let’s discuss.

4 Likes