match tailscale version

This commit is contained in:
Cyryl Płotnicki 2021-06-12 16:46:42 +01:00
parent b1522c6563
commit 3b5f680111
4 changed files with 36 additions and 24 deletions

View file

@ -1,7 +1,10 @@
{ config, pkgs, inputs, lib, ... }: { config, pkgs, inputs, lib, ... }:
{ let
systemd.services.tailscale-autoconnect = { tailscale = inputs.nixpkgs-nixos-unstable.legacyPackages."x86_64-linux".tailscale;
description = "Automatic connection to Tailscale"; in
{
systemd.services.tailscale-autoconnect = {
description = "Automatic connection to Tailscale";
# make sure tailscale is running before trying to connect to tailscale # make sure tailscale is running before trying to connect to tailscale
after = [ "network-pre.target" "tailscale.service" ]; after = [ "network-pre.target" "tailscale.service" ];
@ -12,18 +15,18 @@
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
# have the job run this shell script # have the job run this shell script
script = with pkgs; '' script = ''
# wait for tailscaled to settle # wait for tailscaled to settle
sleep 2 sleep 2
# check if we are already authenticated to tailscale # check if we are already authenticated to tailscale
status="$(${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState)" status="$(${tailscale}/bin/tailscale status -json | ${pkgs.jq}/bin/jq -r .BackendState)"
if [ $status = "Running" ]; then # if so, then do nothing if [ $status = "Running" ]; then # if so, then do nothing
exit 0 exit 0
fi fi
# otherwise authenticate with tailscale # otherwise authenticate with tailscale
${tailscale}/bin/tailscale up -authkey tskey-abb12c2c0f365cfda4f897c7 ${tailscale}/bin/tailscale up -authkey tskey-bd6b308c9c22272a0a66c442
''; '';
}; };
} }

View file

@ -1,7 +1,10 @@
{ config, pkgs, inputs, lib, ... }: { config, pkgs, inputs, lib, ... }:
{ let
systemd.services.tailscale-autoconnect = { tailscale = inputs.nixpkgs-nixos-unstable.legacyPackages."x86_64-linux".tailscale;
description = "Automatic connection to Tailscale"; in
{
systemd.services.tailscale-autoconnect = {
description = "Automatic connection to Tailscale";
# make sure tailscale is running before trying to connect to tailscale # make sure tailscale is running before trying to connect to tailscale
after = [ "network-pre.target" "tailscale.service" ]; after = [ "network-pre.target" "tailscale.service" ];
@ -12,18 +15,18 @@
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
# have the job run this shell script # have the job run this shell script
script = with pkgs; '' script = ''
# wait for tailscaled to settle # wait for tailscaled to settle
sleep 2 sleep 2
# check if we are already authenticated to tailscale # check if we are already authenticated to tailscale
status="$(${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState)" status="$(${tailscale}/bin/tailscale status -json | ${pkgs.jq}/bin/jq -r .BackendState)"
if [ $status = "Running" ]; then # if so, then do nothing if [ $status = "Running" ]; then # if so, then do nothing
exit 0 exit 0
fi fi
# otherwise authenticate with tailscale # otherwise authenticate with tailscale
${tailscale}/bin/tailscale up -authkey tskey-c1640a3f2a7ea4c7b7d96c39 ${tailscale}/bin/tailscale up -authkey tskey-bd6b308c9c22272a0a66c442
''; '';
}; };
} }

View file

@ -1,7 +1,10 @@
{ config, pkgs, inputs, lib, ... }: { config, pkgs, inputs, lib, ... }:
{ let
systemd.services.tailscale-autoconnect = { tailscale = inputs.nixpkgs-nixos-unstable.legacyPackages."x86_64-linux".tailscale;
description = "Automatic connection to Tailscale"; in
{
systemd.services.tailscale-autoconnect = {
description = "Automatic connection to Tailscale";
# make sure tailscale is running before trying to connect to tailscale # make sure tailscale is running before trying to connect to tailscale
after = [ "network-pre.target" "tailscale.service" ]; after = [ "network-pre.target" "tailscale.service" ];
@ -12,18 +15,18 @@
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
# have the job run this shell script # have the job run this shell script
script = with pkgs; '' script = ''
# wait for tailscaled to settle # wait for tailscaled to settle
sleep 2 sleep 2
# check if we are already authenticated to tailscale # check if we are already authenticated to tailscale
status="$(${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState)" status="$(${tailscale}/bin/tailscale status -json | ${pkgs.jq}/bin/jq -r .BackendState)"
if [ $status = "Running" ]; then # if so, then do nothing if [ $status = "Running" ]; then # if so, then do nothing
exit 0 exit 0
fi fi
# otherwise authenticate with tailscale # otherwise authenticate with tailscale
${tailscale}/bin/tailscale up -authkey tskey-abb12c2c0f365cfda4f897c7 ${tailscale}/bin/tailscale up -authkey tskey-bd6b308c9c22272a0a66c442
''; '';
}; };
} }

View file

@ -1,7 +1,10 @@
{ config, pkgs, inputs, lib, ... }: { config, pkgs, inputs, lib, ... }:
{ let
systemd.services.tailscale-autoconnect = { tailscale = inputs.nixpkgs-nixos-unstable.legacyPackages."x86_64-linux".tailscale;
description = "Automatic connection to Tailscale"; in
{
systemd.services.tailscale-autoconnect = {
description = "Automatic connection to Tailscale";
# make sure tailscale is running before trying to connect to tailscale # make sure tailscale is running before trying to connect to tailscale
after = [ "network-pre.target" "tailscale.service" ]; after = [ "network-pre.target" "tailscale.service" ];
@ -12,18 +15,18 @@
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
# have the job run this shell script # have the job run this shell script
script = with pkgs; '' script = ''
# wait for tailscaled to settle # wait for tailscaled to settle
sleep 2 sleep 2
# check if we are already authenticated to tailscale # check if we are already authenticated to tailscale
status="$(${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState)" status="$(${tailscale}/bin/tailscale status -json | ${pkgs.jq}/bin/jq -r .BackendState)"
if [ $status = "Running" ]; then # if so, then do nothing if [ $status = "Running" ]; then # if so, then do nothing
exit 0 exit 0
fi fi
# otherwise authenticate with tailscale # otherwise authenticate with tailscale
${tailscale}/bin/tailscale up -authkey tskey-d6d3e4b981980045e18d0e64 ${tailscale}/bin/tailscale up -authkey tskey-bd6b308c9c22272a0a66c442
''; '';
}; };
} }