sail: Add tailscale
This commit is contained in:
parent
20d7b2c066
commit
b100e88fdd
3 changed files with 32 additions and 0 deletions
Binary file not shown.
|
@ -9,6 +9,7 @@ in
|
|||
../nixos/ssh.nix
|
||||
|
||||
../nixos/git.nix
|
||||
../nixos/tailscale.nix
|
||||
|
||||
../nixos/arion.nix
|
||||
../../container/webserver
|
||||
|
|
31
system/nixos/tailscale.nix
Normal file
31
system/nixos/tailscale.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ pkgs, secret, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = [ pkgs.tailscale ];
|
||||
|
||||
services.tailscale.enable = true;
|
||||
|
||||
systemd.services.tailscale-autoconnect = {
|
||||
description = "Automatic connection to Tailscale";
|
||||
|
||||
after = [ "network-pre.target" "tailscale.service" ];
|
||||
wants = [ "network-pre.target" "tailscale.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig.Type = "oneshot";
|
||||
|
||||
script = ''
|
||||
# wait for tailscaled to settle
|
||||
sleep 2
|
||||
|
||||
# check if we are already authenticated to tailscale
|
||||
status="$(${pkgs.tailscale}/bin/tailscale status -json | ${pkgs.jq}/bin/jq -r .BackendState)"
|
||||
if [ $status = "Running" ]; then # if so, then do nothing
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# otherwise authenticate with tailscale
|
||||
${pkgs.tailscale}/bin/tailscale up -authkey ${secret.tailscale.key}
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue