From f9d5beac96ccc20c84d4deae0878175ee3f8ce3f Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Wed, 31 May 2023 18:08:22 +0200 Subject: [PATCH] temporal: add state config Signed-off-by: Mark Sagi-Kazar --- examples/temporal/devenv.nix | 7 ++++- src/modules/services/temporal.nix | 43 +++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/examples/temporal/devenv.nix b/examples/temporal/devenv.nix index f2482608b..bb6bfa180 100644 --- a/examples/temporal/devenv.nix +++ b/examples/temporal/devenv.nix @@ -5,6 +5,11 @@ namespaces = [ "mynamespace" ]; - ephemeral = false; + state = { + ephemeral = false; + sqlite-pragma = { + journal_mode = "wal"; + }; + }; }; } diff --git a/src/modules/services/temporal.nix b/src/modules/services/temporal.nix index 90f7d8a19..d73ece406 100644 --- a/src/modules/services/temporal.nix +++ b/src/modules/services/temporal.nix @@ -15,7 +15,8 @@ let "--ui-port=${toString cfg.ui.port}" ] ++ (lib.forEach cfg.namespaces (namespace: "--namespace=${namespace}")) ++ - (lib.optionals (!cfg.ephemeral) [ "--db-filename=${databaseFile}" ]); + (lib.optionals (!cfg.state.ephemeral) [ "--db-filename=${databaseFile}" ]) ++ + (lib.mapAttrsToList (name: value: "--sqlite-pragma ${name}=${value}") cfg.state.sqlite-pragma); in { options.services.temporal = { @@ -67,22 +68,38 @@ in description = "UI configuration."; }; - ephemeral = lib.mkOption { - type = types.bool; - default = true; - description = "When enabled, the Temporal state gets lost when the process exists."; - }; - namespaces = lib.mkOption { type = types.listOf types.str; default = [ ]; description = "Specify namespaces that should be pre-created (namespace \"default\" is always created)."; - example = lib.literalExpression '' - [ - "my-namespace" - "my-other-namespace" - ] - ''; + example = [ + "my-namespace" + "my-other-namespace" + ]; + }; + + state = lib.mkOption { + type = types.submodule { + options = { + ephemeral = lib.mkOption { + type = types.bool; + default = true; + description = "When enabled, the Temporal state gets lost when the process exists."; + }; + + sqlite-pragma = lib.mkOption { + type = types.attrsOf types.str; + default = { }; + description = "Sqlite pragma statements"; + example = { + journal_mode = "wal"; + synchronous = "2"; + }; + }; + }; + }; + default = { }; + description = "State configuration."; }; };