9 cfg = config.services.tang;
12 options.services.tang = {
13 enable = mkEnableOption "tang";
18 defaultText = literalExpression "pkgs.tang";
19 description = "The tang package to use.";
22 listenStream = mkOption {
23 type = with types; listOf str;
31 Addresses and/or ports on which tang should listen.
32 For detailed syntax see ListenStream in {manpage}`systemd.socket(5)`.
36 ipAddressAllow = mkOption {
37 example = [ "192.168.1.0/24" ];
38 type = types.listOf types.str;
40 Whitelist a list of address prefixes.
41 Preferably, internal addresses should be used.
46 config = mkIf cfg.enable {
47 environment.systemPackages = [ cfg.package ];
49 systemd.services."tangd@" = {
50 description = "Tang server";
51 path = [ cfg.package ];
53 StandardInput = "socket";
54 StandardOutput = "socket";
55 StandardError = "journal";
57 StateDirectory = "tang";
58 RuntimeDirectory = "tang";
59 StateDirectoryMode = "700";
61 CapabilityBoundingSet = [ "" ];
62 ExecStart = "${cfg.package}/libexec/tangd %S/tang";
63 LockPersonality = true;
64 MemoryDenyWriteExecute = true;
65 NoNewPrivileges = true;
66 DeviceAllow = [ "/dev/stdin" ];
67 RestrictAddressFamilies = [ "AF_UNIX" ];
68 DevicePolicy = "strict";
69 PrivateDevices = true;
74 ProtectControlGroups = true;
76 ProtectHostname = true;
77 ProtectKernelLogs = true;
78 ProtectKernelModules = true;
79 ProtectKernelTunables = true;
80 ProtectProc = "invisible";
81 ProtectSystem = "strict";
82 RestrictNamespaces = true;
83 RestrictRealtime = true;
84 RestrictSUIDSGID = true;
85 SystemCallArchitectures = "native";
91 IPAddressDeny = "any";
92 IPAddressAllow = cfg.ipAddressAllow;
96 systemd.sockets.tangd = {
97 description = "Tang server";
98 wantedBy = [ "sockets.target" ];
100 ListenStream = cfg.listenStream;
102 IPAddressDeny = "any";
103 IPAddressAllow = cfg.ipAddressAllow;
107 meta.maintainers = with lib.maintainers; [