Every NixOS rebuild creates a new Tailscale machine

I’m using Tailscale automated in Systemd with this configuration.nix setup. Every time I do a rebuild of NixOS, Tailscale interprets that as a new machine and adds a new entry to its machine list with a number appended, and disconnects the prior version. I end up with a machine list like this:     z11pa-d8-1           tagged-devices linux   offline   z11pa-d8-2           tagged-devices linux   offline   z11pa-d8-3           tagged-devices linux   offline  z11pa-d8-4           tagged-devices linux   offline   z11pa-d8-5           tagged-devices linux   offline  z11pa-d8-6           tagged-devices linux   offline  z11pa-d8-7           tagged-devices linux   -  z11pa-d8             tagged-devices linux   offline

This obviously breaks any script that references the original machine name, ‘z11pa-d8’. Anyone know how to make the current machine persist through rebuilds?

I have /etc/machine-id persisted in my ‘Erase Your Darlings’ setup, so it remains constant across rebuilds.

It might be worth checking carefully if there is an ordering issue between tailscale starting, and this file getting put back in place. Especially if you’re doing anything with tailscale in stage 1, but I don’t think you are.

1 Like

I don’t know the Tailscale internals but are you persisting its state directory /var/lib/tailscale/? If you’re wiping that on every boot, that’d obviously make it create a new identity on every boot; requiring you to login aswell.

1 Like