Repository navigation
Conversation
Exports nixosModules.dmq-node and overlays.default.
coot
left a comment
There was a problem hiding this comment.
I asked codex for a review:
• The documented NixOS setup fails as a standalone module, and fixing the import alone can still leave DMQ waiting forever on a healthy Cardano node because
its socket is not group-writable. Several otherwise valid Cardano configurations also fail evaluation or produce a service that cannot start.
Full review comments:
• [P1] Grant the DMQ account write access to the Cardano socket — /home/work/clients/iog/dmq-node/nix/nixos/dmq-node-service.nix:276-276
With the upstream cardano-node service's default non-socket-activated setup, systemd's 0022 umask leaves the socket at 0755. Linux requires write
permission to connect, so joining cardano-node is insufficient: the socat probe gets EACCES and waits forever even though Cardano is listening. Include
a producer-side socket ACL or group-writable mask in the documented setup; the UMask on this unit only affects DMQ's own socket.
• [P2] Bind the flake inputs in the NixOS example — /home/work/clients/iog/dmq-node/README.md:167-168
Copied into a NixOS module, this example fails with undefined variable 'inputs'. The ... accepts extra arguments but does not bind their names, even
when the caller supplies inputs via specialArgs. Bind inputs explicitly and show how it is passed, or put the import in the flake's nixosSystem.modules
list where the input is already in scope.
• [P2] Resolve relative Shelley genesis paths against the Cardano config — /home/work/clients/iog/dmq-node/nix/nixos/dmq-node-service.nix:23-24
Passing a flat config read from Cardano's published mainnet-config.json fails here: its ShelleyGenesisFile is mainnet-shelley-genesis.json. Cardano
resolves that relative to the config file, but builtins.readFile rejects the relative string. Accept a config path or base directory for resolution, or
show callers how to normalize this field to a Nix path before passing the attrset.
• [P2] Accept Cardano configurations without a Shelley genesis hash — /home/work/clients/iog/dmq-node/nix/nixos/dmq-node-service.nix:30-30
Valid private-network configs, including Cardano's testnet template, omit ShelleyGenesisHash. Both cardano-node and DMQ.Genesis.readGenesis support
this, but the module throws during evaluation. An explicitly null hash already works because configFile filters it out. Treat an absent hash the same
way while preserving verification whenever a hash is supplied.
• [P2] Keep the configured Cardano socket visible inside the unit — /home/work/clients/iog/dmq-node/nix/nixos/dmq-node-service.nix:284-285
A listening, group-writable socket at /tmp/cardano-node.socket is still invisible to the probe because PrivateTmp gives it a different /tmp. ProtectHome
similarly hides sockets under /home and /run/user. In either case the unit reports itself active but never starts DMQ. Expose the configured socket's
directory to the unit, or reject these locations at evaluation with guidance to use a shared path under /run.
• [P2] Account for per-instance Cardano genesis overrides — /home/work/clients/iog/dmq-node/README.md:172-173
If extraNodeConfig or extraNodeInstanceConfig 0 overrides the genesis, nodeConfig here is only the base configuration. The Cardano service merges the
overrides before starting instance 0, while DMQ derives its network magic from the original genesis and can fail the handshake on the very socket
selected below. Show how to pass the effective config, or qualify this example for nodes without genesis overrides.
• [P2] Check the outer type of topology and settings — /home/work/clients/iog/dmq-node/nix/nixos/dmq-node-service.nix:151-152
For example, topology = ./topology.json; passes json.type, but json.generate writes a JSON string containing the store path, not the topology object.
The system evaluates successfully and readTopologyFile then fails on every start. Restrict object-valued options (topology, traceOptions, and
extraSettings) to types.attrsOf json.type, or handle topology files explicitly rather than serializing their paths.
• [P2] Handle privileged ports for the default service account — /home/work/clients/iog/dmq-node/nix/nixos/dmq-node-service.nix:135-138
On a host with the standard net.ipv4.ip_unprivileged_port_start=1024, setting port = 443 passes evaluation and can open the firewall, but the non-root
DMQ process has no CAP_NET_BIND_SERVICE. It fails at bind and restarts indefinitely. Grant the capability conditionally for privileged ports or reject
that configuration explicitly.
• [P3] Limit networkMagic to an unsigned 32-bit value — /home/work/clients/iog/dmq-node/nix/nixos/dmq-node-service.nix:84-84
types.ints.unsigned accepts 4294967296, but the binary rejects the resulting NetworkMagic because it decodes to Word32. This turns an option error into
a restart loop after activation. Use types.ints.u32 to report it during Nix evaluation instead.
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.
|
Thanks, all nine addressed in 2be7731:
|
List of changes
nixosModules.dmq-node(aliasdefault) innix/nixos/dmq-node-service.nix, andoverlays.default, which providespkgs.dmq-node.The module is meant to run next to the
services.cardano-nodemodule from cardano-node 11.2+, as it would in iohk-nix and cardano-parts:cardanoNodeConfigtakes the node's config attrset as it is. The module takes the genesis file and its hash from it, and reads the network magic from that genesis file, so you set them only once.cardanoNodeSocketGroup(defaultcardano-node) is added toSupplementaryGroups, which gives the service access to the node socket without running as the node user.userandgroupboth default todmq-nodeand are created only while left at that default.packagedefaults to this flake'sdmq-node.openFirewallis a separate option, as in nixpkgs modules.topologyandtraceOptionsare required and link to their documentation. dmq-node crashes whenTraceOptionsis missing.extraSettingsadds any other config key; the module asserts that none of them collide with a key the module sets.socketPathis read-only, underRuntimeDirectory.The module file uses only nixpkgs, so iohk-nix or cardano-parts can import it directly and supply their own package.
Tested by evaluating a NixOS system that uses the module, and by the two-pool VM test proposed separately.
Checklist