Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-24.05] nixos/tailscale: add extraSetFlags to configure daemon #333049

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion nixos/modules/services/networking/tailscale.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,21 @@ in {
};

extraUpFlags = mkOption {
description = "Extra flags to pass to {command}`tailscale up`.";
description = ''
Extra flags to pass to {command}`tailscale up`. Only applied if `authKeyFile` is specified.";
'';
type = types.listOf types.str;
default = [];
example = ["--ssh"];
};

extraSetFlags = mkOption {
description = "Extra flags to pass to {command}`tailscale set`.";
type = types.listOf types.str;
default = [];
example = ["--advertise-exit-node"];
};

extraDaemonFlags = mkOption {
description = "Extra flags to pass to {command}`tailscaled`.";
type = types.listOf types.str;
Expand Down Expand Up @@ -120,6 +129,18 @@ in {
'';
};

systemd.services.tailscaled-set = mkIf (cfg.extraSetFlags != []) {
after = ["tailscaled.service"];
wants = ["tailscaled.service"];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
};
script = ''
${cfg.package}/bin/tailscale set ${escapeShellArgs cfg.extraSetFlags}
'';
};

boot.kernel.sysctl = mkIf (cfg.useRoutingFeatures == "server" || cfg.useRoutingFeatures == "both") {
"net.ipv4.conf.all.forwarding" = mkOverride 97 true;
"net.ipv6.conf.all.forwarding" = mkOverride 97 true;
Expand Down