Merge pull request #245570 from jwygoda/tailscaled-autoconnect-options

nixos/tailscale: add extraUpFlags option
This commit is contained in:
Pol Dellaiera 2023-07-29 06:12:26 +02:00 committed by GitHub
commit 80d8a945dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,12 +29,7 @@ in {
description = lib.mdDoc "Username or user ID of the user allowed to to fetch Tailscale TLS certificates for the node.";
};
package = mkOption {
type = types.package;
default = pkgs.tailscale;
defaultText = literalExpression "pkgs.tailscale";
description = lib.mdDoc "The package to use for tailscale";
};
package = lib.mkPackageOptionMD pkgs "tailscale" {};
useRoutingFeatures = mkOption {
type = types.enum [ "none" "client" "server" "both" ];
@ -58,6 +53,13 @@ in {
A file containing the auth key.
'';
};
extraUpFlags = mkOption {
description = lib.mdDoc "Extra flags to pass to {command}`tailscale up`.";
type = types.listOf types.str;
default = [];
example = ["--ssh"];
};
};
config = mkIf cfg.enable {
@ -98,10 +100,10 @@ in {
serviceConfig = {
Type = "oneshot";
};
script = with pkgs; ''
script = ''
status=$(${config.systemd.package}/bin/systemctl show -P StatusText tailscaled.service)
if [[ $status != Connected* ]]; then
${pkgs.tailscale}/bin/tailscale up --auth-key 'file:${cfg.authKeyFile}'
${cfg.package}/bin/tailscale up --auth-key 'file:${cfg.authKeyFile}' ${escapeShellArgs cfg.extraUpFlags}
fi
'';
};