···49 When set to `server` or `both`, IP forwarding will be enabled.
50 '';
51 };
00000000052 };
5354 config = mkIf cfg.enable {
···80 # version mismatches on restart for compatibility with other
81 # linux distros.
82 stopIfChanged = false;
00000000000000083 };
8485 boot.kernel.sysctl = mkIf (cfg.useRoutingFeatures == "server" || cfg.useRoutingFeatures == "both") {
···49 When set to `server` or `both`, IP forwarding will be enabled.
50 '';
51 };
52+53+ authKeyFile = mkOption {
54+ type = types.nullOr types.path;
55+ default = null;
56+ example = "/run/secrets/tailscale_key";
57+ description = lib.mdDoc ''
58+ A file containing the auth key.
59+ '';
60+ };
61 };
6263 config = mkIf cfg.enable {
···89 # version mismatches on restart for compatibility with other
90 # linux distros.
91 stopIfChanged = false;
92+ };
93+94+ systemd.services.tailscaled-autoconnect = mkIf (cfg.authKeyFile != null) {
95+ after = ["tailscale.service"];
96+ wants = ["tailscale.service"];
97+ wantedBy = [ "multi-user.target" ];
98+ serviceConfig = {
99+ Type = "oneshot";
100+ };
101+ script = with pkgs; ''
102+ status=$(${config.systemd.package}/bin/systemctl show -P StatusText tailscaled.service)
103+ if [[ $status != Connected* ]]; then
104+ ${pkgs.tailscale}/bin/tailscale up --auth-key 'file:${cfg.authKeyFile}'
105+ fi
106+ '';
107 };
108109 boot.kernel.sysctl = mkIf (cfg.useRoutingFeatures == "server" || cfg.useRoutingFeatures == "both") {
···46 the LS_COLORS environment variable is set and output is to tty.
47 '';
48 platforms = platforms.all;
49- maintainers = with maintainers; [ ];
50 };
51}
···46 the LS_COLORS environment variable is set and output is to tty.
47 '';
48 platforms = platforms.all;
49+ maintainers = with maintainers; [ nickcao ];
50 };
51}