Deploying Docker Containers with Nix

I’ve slowly been migrating my ansible-based homelab provisioning setup to NixOS. I was worried at first since I wasn’t sure how well it’d support docker and docker-compose, but it’s been almost* flawless so far. The magic lies in virtualisation.oci-containers.containers. Setup The first thing we need to do is enable an oci backend, either docker or podman. I’m used to docker so I went with the rootless version. # virtualization.nix {...}: { virtualisation = { docker.rootless.enable = true; docker.rootless.setSocketVariable = true; docker.autoPrune.enable = true; containerd.enable = true; oci-containers.backend = "docker"; # defaults to podman }; environment.sessionVariables = { DOCKER_HOST = "unix:///run/docker.sock"; # fix for rootless docker }; } [!NOTE] There is the virtualisation.docker.rootless.setSocketVariable option but it didn’t work for me, so I set DOCKER_HOST manually. ...

February 25, 2025 · 3 min

Selfhosting Gitea, Docker, Caddy

[!NOTE] This article’s Caddy v1 code has been updated to Caddy v2. Something I’ve been doing recently is starting to self-host as much as I can. I don’t like relying on businesses, since they can change their services on a whim. I host an IRC network bouncer, a rss feed reader, and so on. But why not a git frontend? It also doesn’t make sense to me that Github isn’t open-source, despite being a company built on git—libre software that powers the programming industry. Gitlab is commendable for actually being open source, but it’s fairly heavy in resource usage and it has a lot of features I don’t really need. ...

May 15, 2018 · 5 min