nixos/scion: make storing path database optional

Storing the SCION path sqlite databases persistently on disk is a valid
setup that improves performance, but may have outstanding bugs that need
to be investigated, so this makes persisent storage optional, off by
default.

Changed files
+31 -9
nixos
+6 -4
nixos/modules/services/networking/scion/scion-control.nix
···
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";
···
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";
···
DynamicUser = true;
Restart = "on-failure";
BindPaths = [ "/dev/shm:/run/shm" ];
-
RuntimeDirectory = "scion-control";
+
${if globalCfg.stateless then "RuntimeDirectory" else "StateDirectory"} = "scion-control";
};
};
};
+5 -3
nixos/modules/services/networking/scion/scion-daemon.nix
···
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";
···
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";
···
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";
};
};
};
+2 -1
nixos/modules/services/networking/scion/scion-dispatcher.nix
···
with lib;
let
+
globalCfg = config.services.scion;
cfg = config.services.scion.scion-dispatcher;
toml = pkgs.formats.toml { };
defaultConfig = {
···
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";
};
};
};
+2 -1
nixos/modules/services/networking/scion/scion-router.nix
···
with lib;
let
+
globalCfg = config.services.scion;
cfg = config.services.scion.scion-router;
toml = pkgs.formats.toml { };
defaultConfig = {
···
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";
};
};
};
+16
nixos/modules/services/networking/scion/scion.nix
···
{
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;