From dad4070a4e6c23cdef31c7d552e55edc338af81a Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 18:53:33 +0000 Subject: continuum: keep written files in the state directory state-file and document-file, and where they apply store-file, store-vote-record and tor.state-dir, default to files in ${env:STATE_DIRECTORY}. The defaults go in when the file is written rather than through the module system: a default that depends on other settings of the same free-form set recurses infinitely there. --- modules/continuum.nix | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'modules/continuum.nix') diff --git a/modules/continuum.nix b/modules/continuum.nix index 1236088..a6b6d8c 100644 --- a/modules/continuum.nix +++ b/modules/continuum.nix @@ -1,6 +1,25 @@ { config, lib, pkgs, ... }: let cfg = config.hrm.continuum; format = pkgs.formats.toml {}; + + # Where an instance keeps the files it writes, unless its settings say so. + # Only those that apply: continuum refuses the others. + stateFiles = settings: let + dir = "\${env:STATE_DIRECTORY}"; + in + lib.optionalAttrs (!(settings.relay-only or false)) { + state-file = "${dir}/state.json"; + document-file = "${dir}/document.automerge"; + } + // lib.optionalAttrs (settings ? store-id || settings ? store-root) { + store-file = "${dir}/store.json"; + } + // lib.optionalAttrs (settings ? store-vote-key) { + store-vote-record = "${dir}/party-record.json"; + } + // lib.optionalAttrs (settings.tor.enable or false) { + tor.state-dir = "${dir}/tor"; + }; in { options.hrm.continuum.instances = lib.mkOption { default = {}; @@ -18,6 +37,10 @@ in { continuum fills in when it starts. In a Nix string, escape them: "\''${env:STATE_DIRECTORY}/node.key". Unescaped, Nix takes env:STATE_DIRECTORY for a URL and drops the braces. + + The files continuum writes default to the state directory: + state-file, document-file, and where they apply store-file, + store-vote-record and tor.state-dir. Keys have no default. ''; type = lib.types.submodule { freeformType = format.type; @@ -34,7 +57,8 @@ in { after = [ "network-online.target" ]; serviceConfig = { ExecStart = "${pkgs.continuum}/bin/continuum --config ${ - format.generate "continuum-${name}.toml" instance.settings + format.generate "continuum-${name}.toml" + (lib.recursiveUpdate (stateFiles instance.settings) instance.settings) }"; # continuum exits with status 0 when a transport stops, too. Restart = "always"; -- cgit v1.3.1