summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-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";