Run local development services with NixOS and systemd

A practical Nix dev-environment pattern that reuses standard NixOS service modules and systemd for local backing services, narrowing the gap between development and production configuration.

What it is: Tweag's tutorial for running local databases and other backing services inside a small NixOS VM launched from a Nix development shell.

Gist: Rather than reimplementing service definitions or introducing a development-only process manager, the setup uses standard NixOS modules from Nixpkgs and systemd inside a local QEMU VM. A vm command added to the dev shell starts the VM; project-specific modules configure services, while production service configuration can be shared where appropriate. The article also describes forwarding services to the host and extending the VM with tools such as lazyjournal for systemd logs.

This trades some memory and boot time for isolation, reproducibility, and production-like systemd behavior. The tutorial assumes Linux; it points macOS users to a separate Darwin branch and notes the additional Linux-builder setup. The linked repository is a demo for the article.

Newsletter angle: A useful middle ground for Nix teams that want realistic local dependencies without maintaining a second service configuration and process-management stack just for development.