Installing Tailscale with Flox

What’s the best way to install and run tailscale with flox? The tailscale package installs the tailscale client and the tailscaled daemon but there’s no systemd unit created for running the daemon. I’ve looked at using flox services to run tailscaled but it needs to run as root and if the flox service command uses sudo then it doesn’t run the command in the flox environment and it can’t find tailscaled.

I was actually doing this a few weeks ago. I think when I was testing, I used screen…so probably not what you’re looking for.

You can do things like making a systemd unit file and having it run

Here’s what I ended up using. (You’ll need to make a couple modifications)

[Unit]
Description=Tailscale VPN Service (via Flox)
Wants=network-pre.target
After=network-pre.target NetworkManager.service systemd-resolved.service

[Service]
ExecStart=/usr/bin/flox activate -d /root/ts -- tailscaled --state=/root/ts/tailscaled.state
ExecStartPost=/usr/bin/flox activate -d /root/ts -- tailscale up
ExecStop=/usr/bin/flox activate -d /root/ts -- tailscaled --cleanup
Restart=on-failure
RestartSec=5s

User=root
Group=root

## Security settings (optional)
#CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
#NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

This worked on Fedora 39. Note you’ll probably want to change some PATHs and such.