9 cfg = config.services.veilid;
10 dataDir = "/var/db/veilid-server";
12 settingsFormat = pkgs.formats.yaml { };
13 configFile = settingsFormat.generate "veilid-server.conf" cfg.settings;
16 config = mkIf cfg.enable {
17 networking.firewall = mkIf cfg.openFirewall {
18 allowedTCPPorts = [ 5150 ];
19 allowedUDPPorts = [ 5150 ];
22 # Based on https://gitlab.com/veilid/veilid/-/blob/main/package/systemd/veilid-server.service?ref_type=heads
23 systemd.services.veilid = {
25 description = "Veilid Headless Node";
26 wants = [ "network-online.target" ];
27 before = [ "network-online.target" ];
28 wantedBy = [ "multi-user.target" ];
29 restartTriggers = [ configFile ];
34 ExecStart = "${pkgs.veilid}/bin/veilid-server -c ${configFile}";
35 ExecReload = "${pkgs.coreutils}/bin/kill -s HUP $MAINPID";
36 KillSignal = "SIGQUIT";
38 WorkingDirectory = "/";
43 CapabilityBoundingSet = "";
44 SystemCallFilter = [ "@system-service" ];
45 MemoryDenyWriteExecute = true;
46 NoNewPrivileges = true;
47 PrivateDevices = true;
52 ProtectControlGroups = true;
53 ProtectKernelLogs = true;
54 ProtectKernelModules = true;
55 ProtectKernelTunables = true;
56 ProtectProc = "invisible";
57 ProtectSystem = "strict";
58 ReadWritePaths = dataDir;
60 RestrictRealtime = true;
61 SystemCallArchitectures = "native";
62 LockPersonality = true;
63 RestrictSUIDSGID = true;
66 users.users.veilid = {
72 users.groups.veilid = { };
75 systemPackages = [ pkgs.veilid ];
77 services.veilid.settings = { };
80 options.services.veilid = {
81 enable = mkEnableOption "Veilid Headless Node";
82 openFirewall = mkOption {
85 description = "Whether to open firewall on ports 5150/tcp, 5150/udp";
89 Build veilid-server.conf with nix expression.
90 Check <link xlink:href="https://veilid.gitlab.io/developer-book/admin/config.html#configuration-keys">Configuration Keys</link>.
92 type = types.submodule {
93 freeformType = settingsFormat.type;
97 ipc_enabled = mkOption {
100 description = "veilid-server will respond to Python and other JSON client requests.";
102 ipc_directory = mkOption {
104 default = "${dataDir}/ipc";
105 description = "IPC directory where file sockets are stored.";
113 description = "Events of type 'system' will be logged.";
119 description = "The minimum priority of system events to be logged.";
126 description = "Events of type 'terminal' will be logged.";
132 description = "The minimum priority of terminal events to be logged.";
139 description = "Events of type 'api' will be logged.";
145 description = "The minimum priority of api events to be logged.";
152 type = types.listOf types.str;
154 example = [ "APPM" ];
155 description = "A list of capabilities to disable (for example, DHTV to say you cannot store DHT information).";
159 allow_insecure_fallback = mkOption {
162 description = "If we can't use system-provided secure storage, should we proceed anyway?";
164 always_use_insecure_storage = mkOption {
167 description = "Should we bypass any attempt to use system-provided secure storage?";
169 directory = mkOption {
171 default = "${dataDir}/protected_store";
172 description = "The filesystem directory to store your protected store in.";
176 directory = mkOption {
178 default = "${dataDir}/table_store";
179 description = "The filesystem directory to store your table store within.";
183 directory = mkOption {
184 type = types.nullOr types.str;
185 default = "${dataDir}/block_store";
186 description = "The filesystem directory to store blocks for the block store.";
191 bootstrap = mkOption {
192 type = types.listOf types.str;
193 default = [ "bootstrap.veilid.net" ];
194 description = "Host name of existing well-known Veilid bootstrap servers for the network to connect to.";
196 node_id = lib.mkOption {
197 type = lib.types.nullOr lib.types.str;
199 description = "Base64-encoded public key for the node, used as the node's ID.";
203 min_peer_count = mkOption {
206 description = "Minimum number of nodes to keep in the peer table.";
212 description = "Should the app try to improve its incoming network connectivity using UPnP?";
214 detect_address_changes = mkOption {
217 description = "Should veilid-core detect and notify on network address changes?";
226 meta.maintainers = with maintainers; [ figboy9 ];