1 { config, lib, pkgs, ... }:
13 cfg = config.services.tailscaleAuth;
16 options.services.tailscaleAuth = {
17 enable = mkEnableOption "tailscale.nginx-auth, to authenticate users via tailscale";
19 package = mkPackageOption pkgs "tailscale-nginx-auth" {};
23 default = "tailscale-nginx-auth";
24 description = "User which runs tailscale-nginx-auth";
29 default = "tailscale-nginx-auth";
30 description = "Group which runs tailscale-nginx-auth";
33 socketPath = mkOption {
34 default = "/run/tailscale-nginx-auth/tailscale-nginx-auth.sock";
37 Path of the socket listening to authorization requests.
42 config = mkIf cfg.enable {
43 services.tailscale.enable = true;
45 users.users.${cfg.user} = {
49 users.groups.${cfg.group} = { };
51 systemd.sockets.tailscale-nginx-auth = {
52 description = "Tailscale NGINX Authentication socket";
53 partOf = [ "tailscale-nginx-auth.service" ];
54 wantedBy = [ "sockets.target" ];
55 listenStreams = [ cfg.socketPath ];
58 SocketUser = cfg.user;
59 SocketGroup = cfg.group;
63 systemd.services.tailscale-nginx-auth = {
64 description = "Tailscale NGINX Authentication service";
65 requires = [ "tailscale-nginx-auth.socket" ];
68 ExecStart = getExe cfg.package;
69 RuntimeDirectory = "tailscale-nginx-auth";
73 BindPaths = [ "/run/tailscale/tailscaled.sock" ];
75 CapabilityBoundingSet = "";
77 LockPersonality = true;
78 MemoryDenyWriteExecute = true;
79 PrivateDevices = true;
82 ProtectControlGroups = true;
84 ProtectHostname = true;
85 ProtectKernelLogs = true;
86 ProtectKernelModules = true;
87 ProtectKernelTunables = true;
88 RestrictNamespaces = true;
89 RestrictAddressFamilies = [ "AF_UNIX" ];
90 RestrictRealtime = true;
91 RestrictSUIDSGID = true;
93 SystemCallArchitectures = "native";
94 SystemCallErrorNumber = "EPERM";
97 "~@cpu-emulation" "~@debug" "~@keyring" "~@memlock" "~@obsolete" "~@privileged" "~@setuid"
103 meta.maintainers = with maintainers; [ dan-theriault phaer ];