Using ocsigenserver with Nix

I’m trying to create an ocsigen project from scratch to use it with the Nix package manager. This is the repository I have now. Sadly, when I try to run it with ocsigenserver -c todo_ocsigen.conf, I get the following error:

.ocsigenserver-wrapped: main: Fatal - While loading /nix/store/43d97qz3ph3k67d65bs2xzbn7wz76bxm-ocaml5.1.1-eliom-10.4.1/lib/ocaml/5.1.1/site-lib/eliom/server/eliom_server.cma: no implementation available for Ocsipersist

It doesn’t seem to be a problem with findlib, because utop can locate ocsigen-sqlite. What can I possibly be missing, in this case?

Ocsigen-server dynamically loads the extensions specified in the config file and it has more dependencies than you expect (eg. the OCAMLPATH env var).

I think it’s planned to get rid of the dynamic linking and the config file: Using Ocsigen Server without configuration file (and with static linking) by balat · Pull Request #238 · ocsigen/ocsigenserver · GitHub

I was able to build an ocsigen app with Nix using opam-nix, which builds the equivalent of an opam switch and using that as a runtime dependency (which is huge): ocsigen-tictactoe/flake.nix at main · Julow/ocsigen-tictactoe · GitHub

Can you show your config file? Do you load an implementation of ocsipersist from it? Which version of ocsipersist-sqlite do you have?

The config file is in the repository I sent.

Didn’t @Juloo provide a solution that works?

Are you using Ocsipersist 1 or 2?
Did you test without Nix?

The error message seems to indicate that ocsipersist is loaded but not ocsipersist-sqlite (ocsipersist contains the interface and ocsipersist-sqlite is an implementation of this interface).
What is strange is that you load ocsipersist-sqlite before eliom in the config file (which is ok) but you get the error message when you load Eliom (as if you loaded ocsipersist instead of ocsipersist-sqlite) …

I don’t know anything about Nix but why isn’t ocsipersist-sqlite in the same section as the others?
Both Eliom and ocsipersist-sqlite should be runtime dependencies.

Let us know about your progress

Sadly his repository fails to build here, with both nix develop and nix build.

I put ocsipersist-sqlite in that other section because it wasn’t being detected, so I kept trying more “visible” sections than the others. There are some different build inputs in Nix:

  • buildInputs
  • nativeBuildInputs
  • propagatedBuildInputs
  • propagatedNativeBuildInputs

I tried all of them before giving up and asking here.

A good reminder for me that I don’t understand anything in the way Nix handles runtime dependencies :smile:

I forgot to reply, but I cannot use your repository, the build fails with both nix develop and nix build.

I think I’ll give up on Ocsigen while they’re replacing dynamic linking with static linking. However, Nix should probably support Ocaml’s dynamic linking stuff better.