NixCon 2024

Enabling incremental adoption of NixOS with module contracts
2024-10-26 , Arena

I personally believe NixOS to be the ultimate server management tool. But how to convince others? We must let them try NixOS!

Currently, the only way to try out NixOS is to go all-in. There's no way to get a feel for it by just replacing one small piece of an existing infrastructure. To ease and accelerate adoption of NixOS, this must change.

This talk goes over why module contracts is the essential and (yet!) missing piece that will help us spread adoption of NixOS.


Take the Nextcloud module. It is a wonderful module and I am one of its happy users. In a few options, it sets up a complicated beast of infrastructure in an elegant way. It even let's you choose which database you want to use!

There's a caveat, though. Like most of the modules in NixOS, it assumes ownership of its runtime dependencies. This makes it impossible to tell the module to use a database on another host, for example. One could modify the module to add this use case, but this quickly becomes not maintainable. It would make the module even bigger, even harder to test. Also, other modules could benefit from this nice feature and we can't just add this to all of them by copy pasting code around.

What if instead, the Nextcloud module did not own its runtime dependencies. What if the user, you, were in charge of spinning up a database and letting the Nextcloud module configure its database on that instance. Same for the Nextcloud cache, the reverse proxy, the backup service, etc. This dependency inversion is what module contracts is about.

This talk explores what a world with NixOS modules relying on contracts would look like. We'll see how one would configure a Nextcloud module using contracts. Also what it would look like to test it in their current infrastructure. We'll also go over other benefits of contracts. Finally, I'll showcase my project which explores contracts and what is already possible today and what the future plans are.


What level of experience in Nix is the talk addressed to?:

All level of experience are welcome although some familiarity with NixOS modules will make you appreciate the talk even more.

Do you allow your talk to be recorded?: yes

I'm a self-hosting, privacy and data sovereignty advocate.

For 12 years now, I have been self hosting everything I can because I firmly believe it's the only way to keep my data under control. I went through the full spectrum of imperative scripts to fully declarative configuration with NixOS. My mission now is to lower the bar of entry for self-hosting and allow less technical users to get the same benefits I enjoy.

I'm a father of 6 kids and married to a wonderful wife. <3