From f7b9fd4b39c2a41cb1777ee3f0e3651b81a11b37 Mon Sep 17 00:00:00 2001 From: Michael Fellinger Date: Thu, 12 Nov 2026 23:44:08 +0100 Subject: [PATCH 1/3] nix: add a NixOS module for dmq-node Exports nixosModules.dmq-node and overlays.default. --- README.md | 27 ++++ flake.nix | 22 ++- nix/nixos/dmq-node-service.nix | 288 +++++++++++++++++++++++++++++++++ 3 files changed, 334 insertions(+), 3 deletions(-) create mode 100644 nix/nixos/dmq-node-service.nix diff --git a/README.md b/README.md index 56ca0f74..f550da07 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,33 @@ By default all counters are prefixed with `dmq_node_`, this can be changed with } ``` +### NixOS + +The flake exports `nixosModules.dmq-node`, which configures +`services.dmq-node`. It reads the Shelley genesis and the cardano network magic +from the attached node's flat configuration: + +```nix +{ config, ... }: { + imports = [ inputs.dmq-node.nixosModules.dmq-node ]; + services.dmq-node = { + enable = true; + networkMagic = 2912307721; + cardanoNodeConfig = config.services.cardano-node.nodeConfig; + cardanoNodeSocketPath = config.services.cardano-node.socketPath 0; + hostAddr = "0.0.0.0"; + openFirewall = true; + topology = { localRoots = [ ]; publicRoots = [ ]; useLedgerAfterSlot = -1; }; + traceOptions."" = { backends = [ "Stdout MachineFormat" ]; severity = "Info"; }; + }; +} +``` + +`nix/nixos/dmq-node-service.nix` holds the module with no reference to this +flake, so it can be imported by path. There `package` defaults to +`pkgs.dmq-node`, which `overlays.default` adds; set `package` instead to pin +another build. + ## Developing with Nix To enter a development shell with all dependencies available, use: diff --git a/flake.nix b/flake.nix index 32ff6924..7c51fedc 100644 --- a/flake.nix +++ b/flake.nix @@ -41,7 +41,23 @@ flake-utils.url = "github:numtide/flake-utils"; }; - outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system: - import ./nix/outputs.nix { inherit inputs system; } - ); + outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem + (system: + import ./nix/outputs.nix { inherit inputs system; } + ) // { + overlays.default = final: _prev: { + inherit (inputs.self.packages.${final.stdenv.hostPlatform.system}) dmq-node; + }; + + # Defaults `package` directly rather than adding the overlay: NixOS rejects + # `nixpkgs.overlays` when `nixpkgs.pkgs` is set from outside. + nixosModules = rec { + dmq-node = { lib, pkgs, ... }: { + imports = [ ./nix/nixos/dmq-node-service.nix ]; + services.dmq-node.package = lib.mkDefault + inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.dmq-node; + }; + default = dmq-node; + }; + }; } diff --git a/nix/nixos/dmq-node-service.nix b/nix/nixos/dmq-node-service.nix new file mode 100644 index 00000000..3e312f47 --- /dev/null +++ b/nix/nixos/dmq-node-service.nix @@ -0,0 +1,288 @@ +# NixOS service module for dmq-node. +# +# Self-contained: it references nothing from this flake, so it can be imported +# by path. +{ config, lib, pkgs, ... }: + +let + inherit (lib) mkEnableOption mkIf mkOption mkPackageOption types; + + cfg = config.services.dmq-node; + json = pkgs.formats.json { }; + + # The unit's only writable path under ProtectSystem = "strict". + runtimeDirectory = "dmq-node"; + + # User and group the module creates, and only while they are the defaults. + defaultAccount = "dmq-node"; + + requiredNodeConfigKey = key: + cfg.cardanoNodeConfig.${key} or (throw + "services.dmq-node.cardanoNodeConfig has no `${key}`; it must be a flat cardano-node config, such as services.cardano-node.nodeConfig or cardanoLib.environments..nodeConfig"); + + shelleyGenesisFile = requiredNodeConfigKey "ShelleyGenesisFile"; + shelleyGenesis = builtins.fromJSON (builtins.readFile shelleyGenesisFile); + + generatedSettings = { + NetworkMagic = cfg.networkMagic; + CardanoNetworkMagic = shelleyGenesis.networkMagic; + ShelleyGenesisFile = "${shelleyGenesisFile}"; + ShelleyGenesisHash = requiredNodeConfigKey "ShelleyGenesisHash"; + IPv4 = cfg.hostAddr; + IPv6 = cfg.ipv6HostAddr; + PortNumber = cfg.port; + LocalAddress = cfg.socketPath; + CardanoNodeSocket = cfg.cardanoNodeSocketPath; + TraceOptions = cfg.traceOptions; + }; + + duplicatedKeys = lib.intersectLists + (lib.attrNames generatedSettings) + (lib.attrNames cfg.extraSettings); + + configFile = json.generate "dmq-node-config.json" + (lib.filterAttrs (_: v: v != null) generatedSettings // cfg.extraSettings); + + topologyFile = json.generate "dmq-node-topology.json" cfg.topology; + + # dmq-node exits when it cannot reach cardano-node, which only listens once + # its ledger replay is done (hours on mainnet). Waiting here, as the main + # process, keeps the unit active and out of systemd's start limits. + # Connecting, not just testing for the file: a stopped node leaves its socket + # file behind. + dmqNode = pkgs.writeShellApplication { + name = "dmq-node-when-cardano-node-listens"; + runtimeInputs = [ pkgs.socat ]; + text = '' + socket=${lib.escapeShellArg cfg.cardanoNodeSocketPath} + if ! socat -u /dev/null "UNIX-CONNECT:$socket" 2>/dev/null; then + echo "Waiting for cardano-node to listen on $socket ..." + until socat -u /dev/null "UNIX-CONNECT:$socket" 2>/dev/null; do + sleep 5 + done + fi + exec ${lib.escapeShellArgs [ + (lib.getExe' cfg.package "dmq-node") + "--configuration-file" + configFile + "--topology-file" + topologyFile + ]} + ''; + }; +in +{ + options.services.dmq-node = { + enable = mkEnableOption "the DMQ node"; + + package = mkPackageOption pkgs "dmq-node" { }; + + networkMagic = mkOption { + type = types.ints.unsigned; + description = "Network magic of the DMQ network (CIP-137); mainnet is 2912307721."; + }; + + cardanoNodeConfig = mkOption { + type = types.attrs; + example = lib.literalExpression "config.services.cardano-node.nodeConfig"; + description = '' + The flat cardano-node configuration of the node this DMQ node attaches + to. `ShelleyGenesisFile` and `ShelleyGenesisHash` are read from it, and + the cardano network magic is read from that genesis file. + + cardano-node keeps this attrset flat under both `configFormat` dialects + and envelopes it only when writing its config file. + ''; + }; + + cardanoNodeSocketPath = mkOption { + type = types.str; + example = lib.literalExpression "config.services.cardano-node.socketPath 0"; + description = '' + Node-to-client socket of the cardano-node. The service waits until + cardano-node accepts connections on it before starting dmq-node, + which exits when that connection fails. + ''; + }; + + cardanoNodeSocketGroup = mkOption { + type = types.str; + default = "cardano-node"; + description = '' + Group owning the cardano-node socket; the service joins it as a + supplementary group to connect. The default is the group that + cardano-node's NixOS module runs as, so its socket has that group. + ''; + }; + + hostAddr = mkOption { + type = types.nullOr types.str; + default = null; + example = "0.0.0.0"; + description = "IPv4 address to bind node-to-node connections to."; + }; + + ipv6HostAddr = mkOption { + type = types.nullOr types.str; + default = null; + example = "::"; + description = "IPv6 address to bind node-to-node connections to."; + }; + + port = mkOption { + type = types.port; + default = 3141; + description = "Node-to-node TCP port."; + }; + + socketPath = mkOption { + type = types.str; + readOnly = true; + default = "/run/${runtimeDirectory}/dmq-node.socket"; + description = '' + Node-to-client socket that DMQ clients connect to. Fixed inside the + service's runtime directory, the only path the unit may write. + ''; + }; + + topology = mkOption { + inherit (json) type; + example = { + localRoots = [{ + accessPoints = [{ address = "dmq.example.org"; port = 3141; }]; + advertise = false; + trustable = true; + valency = 1; + }]; + publicRoots = [ ]; + useLedgerAfterSlot = -1; + }; + description = '' + Peers to connect to, in cardano-node's topology syntax: + . + + The access points are other dmq-nodes (port 3141 by default), not + cardano-nodes. `bootstrapPeers` and `peerSnapshotFile` are not + supported. Ledger peers additionally need `LedgerPeers = true` in + `extraSettings` and SRV relay records (CIP-155); see the dmq-node + README. + ''; + }; + + traceOptions = mkOption { + inherit (json) type; + example = { + "" = { backends = [ "Stdout MachineFormat" ]; severity = "Info"; }; + "Net.PeerSelection" = { severity = "Debug"; }; + }; + description = '' + trace-dispatcher `TraceOptions`: per trace namespace, its `severity`, + `detail`, `maxFrequency` and `backends`. The `""` namespace sets the + defaults the others refine. See the Configuration section of + . + + Required: dmq-node rejects a configuration file without it. A + `PrometheusSimple` backend exposes metrics, prefixed `dmq_node_`. + ''; + }; + + user = mkOption { + type = types.str; + default = defaultAccount; + description = '' + User the service runs as. The module creates it only under the + default name; another name must be an existing account. + ''; + }; + + group = mkOption { + type = types.str; + default = defaultAccount; + description = '' + Group the service runs as. Its members get access to the + node-to-client socket. The module creates it only under the default + name. + ''; + }; + + openFirewall = mkOption { + type = types.bool; + default = false; + description = "Open `port` in the firewall."; + }; + + extraSettings = mkOption { + inherit (json) type; + default = { }; + example = { LedgerPeers = true; PeerSharing = false; }; + description = '' + Further keys of the dmq-node configuration file. Keys that the options + above already set are rejected. + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + { + assertion = cfg.hostAddr != null || cfg.ipv6HostAddr != null; + message = "services.dmq-node: set hostAddr, ipv6HostAddr or both."; + } + { + assertion = duplicatedKeys == [ ]; + message = "services.dmq-node.extraSettings sets keys owned by other options: ${toString duplicatedKeys}"; + } + ]; + + users = { + users = mkIf (cfg.user == defaultAccount) { + ${defaultAccount} = { + isSystemUser = true; + inherit (cfg) group; + }; + }; + groups = mkIf (cfg.group == defaultAccount) { + ${defaultAccount} = { }; + }; + }; + + networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ]; + + systemd.services.dmq-node = { + description = "DMQ node"; + wantedBy = [ "multi-user.target" ]; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; + + # dmq-node also exits when a running cardano-node restarts. Every such + # restart is a start here, so no start limit: a bounded one would leave + # dmq-node failed after a few node restarts. + startLimitIntervalSec = 0; + + serviceConfig = { + ExecStart = lib.getExe dmqNode; + Restart = "always"; + RestartSec = "10s"; + + User = cfg.user; + Group = cfg.group; + SupplementaryGroups = [ cfg.cardanoNodeSocketGroup ]; + NoNewPrivileges = true; + RuntimeDirectory = runtimeDirectory; + RuntimeDirectoryMode = "0750"; + # The node-to-client socket must be group-writable for clients. + UMask = "0007"; + + ProtectSystem = "strict"; + ProtectHome = true; + PrivateTmp = true; + PrivateDevices = true; + ProtectKernelTunables = true; + ProtectKernelModules = true; + ProtectControlGroups = true; + RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ]; + LockPersonality = true; + }; + }; + }; +} From a69e11a3bb0cbdeafed06b2127e6881be609c279 Mon Sep 17 00:00:00 2001 From: Michael Fellinger Date: Tue, 24 Nov 2026 13:44:15 +0100 Subject: [PATCH 2/3] nixos: collect GHC runtime stats and document Prometheus metrics --- README.md | 24 +++++++++++++++++++++--- nix/nixos/dmq-node-service.nix | 13 ++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f550da07..c2e86ff6 100644 --- a/README.md +++ b/README.md @@ -149,8 +149,8 @@ The `Prometheus` requires a different port number than `cardano-node`'s } ``` -By default all counters are prefixed with `dmq_node_`, this can be changed with -`TraceOptionMetricsPrefix` option in the configuration file, e.g. +DMQ metrics use the prefix `dmq_node_` by default. To change it, set +`TraceOptionMetricsPrefix` in the configuration file, e.g. ```json { "TraceOptionMetricsPrefix": "dmq_aggregator." @@ -174,11 +174,29 @@ from the attached node's flat configuration: hostAddr = "0.0.0.0"; openFirewall = true; topology = { localRoots = [ ]; publicRoots = [ ]; useLedgerAfterSlot = -1; }; - traceOptions."" = { backends = [ "Stdout MachineFormat" ]; severity = "Info"; }; + traceOptions."" = { + backends = [ "Stdout MachineFormat" "PrometheusSimple suffix 127.0.0.1 12800" ]; + severity = "Info"; + }; }; } ``` +With this configuration, a Prometheus instance on the same host can scrape +`127.0.0.1:12800` at its default path, `/metrics`. To inspect it directly: + +```sh +curl -fsS http://127.0.0.1:12800/metrics +``` + +`dmq_node_peerSelection_ActivePeers_int` reports the current active peer count. +For messages received from peers, look for `dmq_node_txSubmission_txsReceived_int`, +`dmq_node_txSubmission_txsAccepted_int` and `dmq_node_txSubmission_txsRejected_int`. +The V2 submission worker checks for changed totals every seven seconds, so these +series can be absent from an early scrape. The NixOS service enables GHC runtime +statistics with `+RTS -T -RTS`, including `rts_gc_bytes_allocated` and +`rts_gc_num_gcs`. + `nix/nixos/dmq-node-service.nix` holds the module with no reference to this flake, so it can be imported by path. There `package` defaults to `pkgs.dmq-node`, which `overlays.default` adds; set `package` instead to pin diff --git a/nix/nixos/dmq-node-service.nix b/nix/nixos/dmq-node-service.nix index 3e312f47..09df6040 100644 --- a/nix/nixos/dmq-node-service.nix +++ b/nix/nixos/dmq-node-service.nix @@ -67,6 +67,9 @@ let configFile "--topology-file" topologyFile + "+RTS" + "-T" + "-RTS" ]} ''; }; @@ -172,7 +175,10 @@ in traceOptions = mkOption { inherit (json) type; example = { - "" = { backends = [ "Stdout MachineFormat" ]; severity = "Info"; }; + "" = { + backends = [ "Stdout MachineFormat" "PrometheusSimple suffix 127.0.0.1 12800" ]; + severity = "Info"; + }; "Net.PeerSelection" = { severity = "Debug"; }; }; description = '' @@ -181,8 +187,9 @@ in defaults the others refine. See the Configuration section of . - Required: dmq-node rejects a configuration file without it. A - `PrometheusSimple` backend exposes metrics, prefixed `dmq_node_`. + dmq-node requires this option. The example serves DMQ metrics + (`dmq_node_*`) and GHC runtime statistics (`rts_gc_*`) at + `http://127.0.0.1:12800/metrics`. ''; }; From 2be7731fae4e9d66bb55c6e14875d7bf9dacd110 Mon Sep 17 00:00:00 2001 From: Michael Fellinger Date: Fri, 27 Nov 2026 14:46:21 +0100 Subject: [PATCH 3/3] nixos: address review of the dmq-node module Fail on unwritable or sandbox-hidden node sockets and relative genesis paths; optional genesis hash, object-typed JSON options, u32 magic, bind cap below 1024. --- README.md | 40 ++++++++++------- nix/nixos/dmq-node-service.nix | 82 ++++++++++++++++++++++++++++------ 2 files changed, 92 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index c2e86ff6..dc50991d 100644 --- a/README.md +++ b/README.md @@ -161,24 +161,32 @@ DMQ metrics use the prefix `dmq_node_` by default. To change it, set The flake exports `nixosModules.dmq-node`, which configures `services.dmq-node`. It reads the Shelley genesis and the cardano network magic -from the attached node's flat configuration: +from the attached node's flat configuration. dmq-node connects to the node +socket through the node's group, so that socket must be group-writable; the +example uses socket activation for this, and the `cardanoNodeSocketGroup` +option lists the alternatives. In a flake's `nixosSystem`: ```nix -{ config, ... }: { - imports = [ inputs.dmq-node.nixosModules.dmq-node ]; - services.dmq-node = { - enable = true; - networkMagic = 2912307721; - cardanoNodeConfig = config.services.cardano-node.nodeConfig; - cardanoNodeSocketPath = config.services.cardano-node.socketPath 0; - hostAddr = "0.0.0.0"; - openFirewall = true; - topology = { localRoots = [ ]; publicRoots = [ ]; useLedgerAfterSlot = -1; }; - traceOptions."" = { - backends = [ "Stdout MachineFormat" "PrometheusSimple suffix 127.0.0.1 12800" ]; - severity = "Info"; - }; - }; +nixpkgs.lib.nixosSystem { + modules = [ + inputs.dmq-node.nixosModules.dmq-node + ({ config, ... }: { + services.cardano-node.systemdSocketActivation = true; + services.dmq-node = { + enable = true; + networkMagic = 2912307721; + cardanoNodeConfig = config.services.cardano-node.nodeConfig; + cardanoNodeSocketPath = config.services.cardano-node.socketPath 0; + hostAddr = "0.0.0.0"; + openFirewall = true; + topology = { localRoots = [ ]; publicRoots = [ ]; useLedgerAfterSlot = -1; }; + traceOptions."" = { + backends = [ "Stdout MachineFormat" "PrometheusSimple suffix 127.0.0.1 12800" ]; + severity = "Info"; + }; + }; + }) + ]; } ``` diff --git a/nix/nixos/dmq-node-service.nix b/nix/nixos/dmq-node-service.nix index 09df6040..c6d414d3 100644 --- a/nix/nixos/dmq-node-service.nix +++ b/nix/nixos/dmq-node-service.nix @@ -9,6 +9,8 @@ let cfg = config.services.dmq-node; json = pkgs.formats.json { }; + # json.type also accepts a path, which json.generate writes as a string. + jsonObject = types.attrsOf json.type; # The unit's only writable path under ProtectSystem = "strict". runtimeDirectory = "dmq-node"; @@ -20,14 +22,24 @@ let cfg.cardanoNodeConfig.${key} or (throw "services.dmq-node.cardanoNodeConfig has no `${key}`; it must be a flat cardano-node config, such as services.cardano-node.nodeConfig or cardanoLib.environments..nodeConfig"); - shelleyGenesisFile = requiredNodeConfigKey "ShelleyGenesisFile"; + # cardano-node resolves a relative genesis path against its config file, + # whose location an attrset no longer carries. + shelleyGenesisFile = + let file = requiredNodeConfigKey "ShelleyGenesisFile"; + in + if types.path.check file then file + else + throw + "services.dmq-node.cardanoNodeConfig.ShelleyGenesisFile must be an absolute path, got `${file}`; override it, e.g. `// { ShelleyGenesisFile = ./${file}; }`"; shelleyGenesis = builtins.fromJSON (builtins.readFile shelleyGenesisFile); generatedSettings = { NetworkMagic = cfg.networkMagic; CardanoNetworkMagic = shelleyGenesis.networkMagic; ShelleyGenesisFile = "${shelleyGenesisFile}"; - ShelleyGenesisHash = requiredNodeConfigKey "ShelleyGenesisHash"; + # Optional for cardano-node and dmq-node alike: without it, neither + # verifies the genesis file. + ShelleyGenesisHash = cfg.cardanoNodeConfig.ShelleyGenesisHash or null; IPv4 = cfg.hostAddr; IPv6 = cfg.ipv6HostAddr; PortNumber = cfg.port; @@ -36,6 +48,20 @@ let TraceOptions = cfg.traceOptions; }; + # Sandbox settings the unit enables, with the directories each one hides. + sandboxHides = { + PrivateTmp = [ "/tmp/" "/var/tmp/" ]; + ProtectHome = [ "/home/" "/root/" "/run/user/" ]; + }; + hiddenSocketDirs = lib.filter + (dir: lib.hasPrefix dir cfg.cardanoNodeSocketPath) + (lib.concatLists (lib.attrValues sandboxHides)); + + # Ports below 1024 need the capability under the kernel's default + # ip_unprivileged_port_start. A string, not a list: NixOS writes no line for + # an empty list, while an empty assignment is systemd's empty set. + capabilities = lib.optionalString (cfg.port < 1024) "CAP_NET_BIND_SERVICE"; + duplicatedKeys = lib.intersectLists (lib.attrNames generatedSettings) (lib.attrNames cfg.extraSettings); @@ -49,15 +75,23 @@ let # its ledger replay is done (hours on mainnet). Waiting here, as the main # process, keeps the unit active and out of systemd's start limits. # Connecting, not just testing for the file: a stopped node leaves its socket - # file behind. + # file behind. Connecting needs write permission, which no wait grants, so a + # socket we cannot write fails the start instead. dmqNode = pkgs.writeShellApplication { name = "dmq-node-when-cardano-node-listens"; runtimeInputs = [ pkgs.socat ]; text = '' socket=${lib.escapeShellArg cfg.cardanoNodeSocketPath} - if ! socat -u /dev/null "UNIX-CONNECT:$socket" 2>/dev/null; then + connect() { + if [ -S "$socket" ] && [ ! -w "$socket" ]; then + echo "$socket is not writable by group ${cfg.cardanoNodeSocketGroup}; see services.dmq-node.cardanoNodeSocketGroup" >&2 + exit 1 + fi + socat -u /dev/null "UNIX-CONNECT:$socket" 2>/dev/null + } + if ! connect; then echo "Waiting for cardano-node to listen on $socket ..." - until socat -u /dev/null "UNIX-CONNECT:$socket" 2>/dev/null; do + until connect; do sleep 5 done fi @@ -81,7 +115,7 @@ in package = mkPackageOption pkgs "dmq-node" { }; networkMagic = mkOption { - type = types.ints.unsigned; + type = types.ints.u32; description = "Network magic of the DMQ network (CIP-137); mainnet is 2912307721."; }; @@ -90,11 +124,17 @@ in example = lib.literalExpression "config.services.cardano-node.nodeConfig"; description = '' The flat cardano-node configuration of the node this DMQ node attaches - to. `ShelleyGenesisFile` and `ShelleyGenesisHash` are read from it, and - the cardano network magic is read from that genesis file. + to. `ShelleyGenesisFile` and, if present, `ShelleyGenesisHash` are read + from it, and the cardano network magic is read from that genesis file. cardano-node keeps this attrset flat under both `configFormat` dialects and envelopes it only when writing its config file. + + `services.cardano-node.nodeConfig` is the base configuration only. If + the node overrides its genesis through `extraNodeConfig` or + `extraNodeInstanceConfig`, pass the merged attrset instead: + `lib.recursiveUpdate (lib.recursiveUpdate nodeConfig extraNodeConfig) (extraNodeInstanceConfig 0)`. + A `nodeConfigFile` replaces all three. ''; }; @@ -115,6 +155,15 @@ in Group owning the cardano-node socket; the service joins it as a supplementary group to connect. The default is the group that cardano-node's NixOS module runs as, so its socket has that group. + + Connecting needs the socket to be group-writable, which it is not by + default (mode 0755). Make it so on the cardano-node side with one of: + - `services.cardano-node.systemdSocketActivation = true` + (socket mode 0660 with `services.cardano-node.socketGroup`); + - `services.cardano-node.shareNodeSocket = true` under cardano-parts; + - `systemd.services.cardano-node.serviceConfig.UMask = "0007"`. + + The service fails to start while the socket is not writable. ''; }; @@ -149,7 +198,7 @@ in }; topology = mkOption { - inherit (json) type; + type = jsonObject; example = { localRoots = [{ accessPoints = [{ address = "dmq.example.org"; port = 3141; }]; @@ -163,6 +212,7 @@ in description = '' Peers to connect to, in cardano-node's topology syntax: . + To use a topology file, pass `lib.importJSON ./topology.json`. The access points are other dmq-nodes (port 3141 by default), not cardano-nodes. `bootstrapPeers` and `peerSnapshotFile` are not @@ -173,7 +223,7 @@ in }; traceOptions = mkOption { - inherit (json) type; + type = jsonObject; example = { "" = { backends = [ "Stdout MachineFormat" "PrometheusSimple suffix 127.0.0.1 12800" ]; @@ -219,7 +269,7 @@ in }; extraSettings = mkOption { - inherit (json) type; + type = jsonObject; default = { }; example = { LedgerPeers = true; PeerSharing = false; }; description = '' @@ -235,6 +285,10 @@ in assertion = cfg.hostAddr != null || cfg.ipv6HostAddr != null; message = "services.dmq-node: set hostAddr, ipv6HostAddr or both."; } + { + assertion = hiddenSocketDirs == [ ]; + message = "services.dmq-node.cardanoNodeSocketPath is under ${toString hiddenSocketDirs}, which the service's sandbox hides; move the cardano-node socket, e.g. to /run/cardano-node/node.socket."; + } { assertion = duplicatedKeys == [ ]; message = "services.dmq-node.extraSettings sets keys owned by other options: ${toString duplicatedKeys}"; @@ -266,7 +320,7 @@ in # dmq-node failed after a few node restarts. startLimitIntervalSec = 0; - serviceConfig = { + serviceConfig = lib.mapAttrs (_: _: true) sandboxHides // { ExecStart = lib.getExe dmqNode; Restart = "always"; RestartSec = "10s"; @@ -275,14 +329,14 @@ in Group = cfg.group; SupplementaryGroups = [ cfg.cardanoNodeSocketGroup ]; NoNewPrivileges = true; + AmbientCapabilities = capabilities; + CapabilityBoundingSet = capabilities; RuntimeDirectory = runtimeDirectory; RuntimeDirectoryMode = "0750"; # The node-to-client socket must be group-writable for clients. UMask = "0007"; ProtectSystem = "strict"; - ProtectHome = true; - PrivateTmp = true; PrivateDevices = true; ProtectKernelTunables = true; ProtectKernelModules = true;