# Using ocsigenserver with Nix

**URL:** <https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034>\
**Category:** Learning\
**Tags:** ocsigenserver, nix, ocsigen\
**Created:** [July 26, 2024, 6:56pm UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034 "2024-07-26T18:56:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denommus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/denommus/32/5428_2.png) [@Denommus](https://discuss.ocaml.org/u/Denommus)\
**Post date:** [July 26, 2024, 6:56pm UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/1 "2024-07-26T18:56:21Z")

</div>

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](https://github.com/Denommus/todo_ocsigen). Sadly, when I try to run it with `ocsigenserver -c todo_ocsigen.conf`, I get the following error:

```auto
.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?

---

<div class="post-metadata">

**Author:** ![Juloo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/juloo/32/881_2.png) [@Juloo](https://discuss.ocaml.org/u/Juloo)\
**Post date:** [July 27, 2024, 9:52am UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/2 "2024-07-27T09:52:14Z")

</div>

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](https://github.com/ocsigen/ocsigenserver/pull/238)

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](https://github.com/Julow/ocsigen-tictactoe/blob/main/flake.nix)

---

<div class="post-metadata">

**Author:** ![Vincent\_Balat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vincent_balat/32/2191_2.png) [@Vincent\_Balat](https://discuss.ocaml.org/u/Vincent_Balat)\
**Post date:** [July 29, 2024, 9:40am UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/3 "2024-07-29T09:40:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Denommus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/denommus/32/5428_2.png) [@Denommus](https://discuss.ocaml.org/u/Denommus)\
**Post date:** [July 29, 2024, 2:43pm UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/4 "2024-07-29T14:43:25Z")

</div>

The config file is in the repository I sent.

---

<div class="post-metadata">

**Author:** ![otini](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/otini/32/3533_2.png) [@otini](https://discuss.ocaml.org/u/otini)\
**Post date:** [July 31, 2024, 3:22pm UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/5 "2024-07-31T15:22:24Z")

</div>

Didn’t @Juloo provide a solution that works?

---

<div class="post-metadata">

**Author:** ![Vincent\_Balat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vincent_balat/32/2191_2.png) [@Vincent\_Balat](https://discuss.ocaml.org/u/Vincent_Balat)\
**Post date:** [July 31, 2024, 3:30pm UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/6 "2024-07-31T15:30:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Denommus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/denommus/32/5428_2.png) [@Denommus](https://discuss.ocaml.org/u/Denommus)\
**Post date:** [July 31, 2024, 4:17pm UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/7 "2024-07-31T16:17:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Denommus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/denommus/32/5428_2.png) [@Denommus](https://discuss.ocaml.org/u/Denommus)\
**Post date:** [July 31, 2024, 4:19pm UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/8 "2024-07-31T16:19:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![otini](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/otini/32/3533_2.png) [@otini](https://discuss.ocaml.org/u/otini)\
**Post date:** [August 1, 2024, 8:36am UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/9 "2024-08-01T08:36:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Denommus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/denommus/32/5428_2.png) [@Denommus](https://discuss.ocaml.org/u/Denommus)\
**Post date:** [August 2, 2024, 2:18pm UTC](https://discuss.ocaml.org/t/using-ocsigenserver-with-nix/15034/10 "2024-08-02T14:18:06Z")

</div>

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.
