summaryrefslogtreecommitdiffstats
path: root/modules/continuum.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-19 18:53:33 +0000
committertv <tv@krebsco.de>2026-11-19 18:53:33 +0000
commitdad4070a4e6c23cdef31c7d552e55edc338af81a (patch)
tree5cedf7fba772c5a37c11b44faf7e66626d033feb /modules/continuum.nix
parent87b5f6d490d6d18108ef4f7b82b606e77523c26a (diff)
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.
Diffstat (limited to 'modules/continuum.nix')
-rw-r--r--modules/continuum.nix26
1 files changed, 25 insertions, 1 deletions
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";