How to run docker daemon from nix (not NixOS)?

In theory you can just run that binary, you’ll “just” need to do all the configuration by hand. YMMV with apparmor and such.

There are no guides for it because it’s not really an expected use case and distros vary too much for good generic guides. Not even docker themselves document how to bootstrap docker from a build.

There’s currently no good mechanism for configuring services on non-NixOS hosts. Some projects exist that do this, such as home-manager and devshell, and there is an RFC for making the nixpkgs services less NixOS-specific, but I think docker specifically is generally quite complex to configure as it needs to do so much to work, so it will probably be among the last services to work if that much ever becomes possible.

NixOS exists for a reason; doing all the work to make these service configurations without controlling the rest of the environment is a bit of a tall order. You might have more luck switching to NixOS if you really want to do everything with nix.

2 Likes