Nix package manager in fly.io Sprites
Recently I stumbled upon Fly.io’s Sprites.
Tangled uses nix (the package manager) and since I had my development setup for Tangled in a docker container(TODO: add footnote) it was a good excuse to play around with them.
How to install
First, choose the multi-user installation:
sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --daemon
Note: The installer will complain, that you don’t have
systemdinstalled.
This is expected—we will handle that next.
Next, add the nix daemon to the services of your Sprite:
sprite-env services create nix-daemon \
--cmd sudo \
--args /nix/var/nix/profiles/default/bin/nix-daemon
That’s all. Yep.
Errors I encountered
nix develop hangs on copying [something] to the store
This was really annoying, because the Sprite would just crash after a few minutes stuck at this step.
The issue ended up being that the user is not trusted (in the nix context).
To fix it:
- Add
trusted-users = root spriteto/etc/nix/nix.conf - Restart the nix daemon (using
sprite-env)
nix store info hangs at Store URL: daemon
The issue here is most likely, that the daemon is not running as root.
You can verify this with ls -la /nix/var/nix/daemon-socket/socket. The owner should be root (not sprite).
To fix this, make sure you started the daemon with sudo.