diff --git a/nixos/modules/services/networking/scion/scion-control.nix b/nixos/modules/services/networking/scion/scion-control.nix index 95d78a87ac85..0cc190d619b6 100644 --- a/nixos/modules/services/networking/scion/scion-control.nix +++ b/nixos/modules/services/networking/scion/scion-control.nix @@ -3,8 +3,10 @@ with lib; let + globalCfg = config.services.scion; cfg = config.services.scion.scion-control; toml = pkgs.formats.toml { }; + connectionDir = if globalCfg.stateless then "/run" else "/var/lib"; defaultConfig = { general = { id = "cs"; @@ -12,13 +14,13 @@ let reconnect_to_dispatcher = true; }; beacon_db = { - connection = "/run/scion-control/control.beacon.db"; + connection = "${connectionDir}/scion-control/control.beacon.db"; }; path_db = { - connection = "/run/scion-control/control.path.db"; + connection = "${connectionDir}/scion-control/control.path.db"; }; trust_db = { - connection = "/run/scion-control/control.trust.db"; + connection = "${connectionDir}/scion-control/control.trust.db"; }; log.console = { level = "info"; @@ -62,7 +64,7 @@ in DynamicUser = true; Restart = "on-failure"; BindPaths = [ "/dev/shm:/run/shm" ]; - RuntimeDirectory = "scion-control"; + ${if globalCfg.stateless then "RuntimeDirectory" else "StateDirectory"} = "scion-control"; }; }; }; diff --git a/nixos/modules/services/networking/scion/scion-daemon.nix b/nixos/modules/services/networking/scion/scion-daemon.nix index 8528bec1d52e..6ee2a4b505f2 100644 --- a/nixos/modules/services/networking/scion/scion-daemon.nix +++ b/nixos/modules/services/networking/scion/scion-daemon.nix @@ -3,8 +3,10 @@ with lib; let + globalCfg = config.services.scion; cfg = config.services.scion.scion-daemon; toml = pkgs.formats.toml { }; + connectionDir = if globalCfg.stateless then "/run" else "/var/lib"; defaultConfig = { general = { id = "sd"; @@ -12,10 +14,10 @@ let reconnect_to_dispatcher = true; }; path_db = { - connection = "/run/scion-daemon/sd.path.db"; + connection = "${connectionDir}/scion-daemon/sd.path.db"; }; trust_db = { - connection = "/run/scion-daemon/sd.trust.db"; + connection = "${connectionDir}/scion-daemon/sd.trust.db"; }; log.console = { level = "info"; @@ -57,7 +59,7 @@ in ExecStart = "${pkgs.scion}/bin/scion-daemon --config ${configFile}"; Restart = "on-failure"; DynamicUser = true; - RuntimeDirectory = "scion-daemon"; + ${if globalCfg.stateless then "RuntimeDirectory" else "StateDirectory"} = "scion-daemon"; }; }; }; diff --git a/nixos/modules/services/networking/scion/scion-dispatcher.nix b/nixos/modules/services/networking/scion/scion-dispatcher.nix index 7c9f5e6a385e..1f4193fae79e 100644 --- a/nixos/modules/services/networking/scion/scion-dispatcher.nix +++ b/nixos/modules/services/networking/scion/scion-dispatcher.nix @@ -3,6 +3,7 @@ with lib; let + globalCfg = config.services.scion; cfg = config.services.scion.scion-dispatcher; toml = pkgs.formats.toml { }; defaultConfig = { @@ -66,7 +67,7 @@ in ExecStartPre = "${pkgs.coreutils}/bin/rm -rf /run/shm/dispatcher"; ExecStart = "${pkgs.scion}/bin/scion-dispatcher --config ${configFile}"; Restart = "on-failure"; - RuntimeDirectory = "scion-dispatcher"; + ${if globalCfg.stateless then "RuntimeDirectory" else "StateDirectory"} = "scion-dispatcher"; }; }; }; diff --git a/nixos/modules/services/networking/scion/scion-router.nix b/nixos/modules/services/networking/scion/scion-router.nix index 2cac44ab767e..47ff320b6a8f 100644 --- a/nixos/modules/services/networking/scion/scion-router.nix +++ b/nixos/modules/services/networking/scion/scion-router.nix @@ -3,6 +3,7 @@ with lib; let + globalCfg = config.services.scion; cfg = config.services.scion.scion-router; toml = pkgs.formats.toml { }; defaultConfig = { @@ -42,7 +43,7 @@ in ExecStart = "${pkgs.scion}/bin/scion-router --config ${configFile}"; Restart = "on-failure"; DynamicUser = true; - RuntimeDirectory = "scion-router"; + ${if globalCfg.stateless then "RuntimeDirectory" else "StateDirectory"} = "scion-router"; }; }; }; diff --git a/nixos/modules/services/networking/scion/scion.nix b/nixos/modules/services/networking/scion/scion.nix index b8bfef8b93b5..0ae959484d32 100644 --- a/nixos/modules/services/networking/scion/scion.nix +++ b/nixos/modules/services/networking/scion/scion.nix @@ -8,6 +8,22 @@ in { options.services.scion = { enable = mkEnableOption "all of the scion components and services"; + stateless = mkOption { + type = types.bool; + default = true; + description = '' + Setting this value to false (stateful) can lead to improved caching and + performance. + + This option decides whether to persist the SCION path sqlite databases + on disk or not. Persisting this data can lead to database corruption in + extreme cases such as power outage, meaning SCION fails to work on the + next boot. This is being investigated. + + If true, /run/scion-* is used for data + If false, use /var/lib/scion-* is used for data + ''; + }; bypassBootstrapWarning = mkOption { type = types.bool; default = false;