Prolog Tutorial

Nix packaging

Scryer-prolog has good support for the declarative and reproducible buildsystem Nix :)

The repo contains a flake.nix and it is available in nixpkgs. Therefore using scryer with nix is very easy:


nix run nixpkgs#scryer-prolog

Package your own prolog code

Let's have a look at an example…

I packaged the static site generator DocLog, that builds documentation from source code in Prolog.

Btw, this tutorial is written with DocLog ;)

DocLog has 2 external dependencies:

  • teruel is a Tera and Jinja inspired template engine for prolog

  • djota renders the Markdown subset Djot to html

Without nix, the default way of setting up DocLog is using this Makefile.

The nix flake contains:

  • source packages for the dependencies teruel and djota (using fetchFromGitHub)

  • the doclog package created with mkDerivation

  • the apps doclog, doclog_watch and the alias watch point to the relevant binaries and allow trivial usage with nix run


nix run github:aarroyoc/doclog# . www
#-> creates documentation from docstrings in prolog files from `.` and places them into the `www` directory.

nix run github:aarroyoc/doclog#watch . www
#-> this wrapper uses inotifywait to rebuild everytime the source changed