Back Home

Building a website using Nix and OCaml

Posted on Tuesday, 5 November 2024 - 360 words
Suggest An Edit
#nix#ocaml#website

A while ago, I started to use Nix (again) to manage my dependencies. I like the fact that Nix is declarative and being able to define dependencies, config, etc in a file making it reproducible. Overall I like Nix a lot, minus the fact that it’s using a lot of storage space since each package (or derivation in Nix lingo) is stored in a separate directory.

I’ve used Nix before but I didn’t really use it for development environment, I just used it to manage my dotfiles and packages. This time though, I want to try using it to manage my development environment. I’ve also been wanting to try out OCaml for a while, so I thought why not use Nix to manage my OCaml environment, that shouldn’t be too hard right? (inb4 I spent several hours configuring things due to lack of documentation lol)

DISCLAIMER: I would assume you already somewhat familiar with Nix, if not, here’s a few resources to get you started:

Why Nix for development?

Why can’t I just do sudo dnf install nodejs and go on with my life? Why this esoteric thing? Why can’t I just use docker and use it to run my development environment?

Well, there are several reasons for that, I’m not going to go into detail about them, but basically, using Nix to manage your development environment makes it reproducible. What I mean by that is, if there’s someone who wants to contribute, or you want to continue the development in another machine, you can just do nix develop and it will give you a shell with everything you need to start developing.

For now let’s just stick with that, I don’t want to go into details about Nix, there’s already a lot of articles and videos out there that explains it much better than me. I’ve listed few of them below:

If you don't see any comment section, please turn off your adblocker :)