2024-03-24 21:03:03 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2024-07-02 14:57:38 +01:00
|
|
|
globalCfg = config.services.scion;
|
2024-03-24 21:03:03 +00:00
|
|
|
cfg = config.services.scion.scion-control;
|
|
|
|
toml = pkgs.formats.toml { };
|
2024-07-02 14:57:38 +01:00
|
|
|
connectionDir = if globalCfg.stateless then "/run" else "/var/lib";
|
2024-03-24 21:03:03 +00:00
|
|
|
defaultConfig = {
|
|
|
|
general = {
|
|
|
|
id = "cs";
|
|
|
|
config_dir = "/etc/scion";
|
|
|
|
reconnect_to_dispatcher = true;
|
|
|
|
};
|
|
|
|
beacon_db = {
|
2024-07-02 14:57:38 +01:00
|
|
|
connection = "${connectionDir}/scion-control/control.beacon.db";
|
2024-03-24 21:03:03 +00:00
|
|
|
};
|
|
|
|
path_db = {
|
2024-07-02 14:57:38 +01:00
|
|
|
connection = "${connectionDir}/scion-control/control.path.db";
|
2024-03-24 21:03:03 +00:00
|
|
|
};
|
|
|
|
trust_db = {
|
2024-07-02 14:57:38 +01:00
|
|
|
connection = "${connectionDir}/scion-control/control.trust.db";
|
2024-03-24 21:03:03 +00:00
|
|
|
};
|
|
|
|
log.console = {
|
|
|
|
level = "info";
|
|
|
|
};
|
|
|
|
};
|
2024-06-25 13:31:27 +01:00
|
|
|
configFile = toml.generate "scion-control.toml" (recursiveUpdate defaultConfig cfg.settings);
|
2024-03-24 21:03:03 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.scion.scion-control = {
|
|
|
|
enable = mkEnableOption "the scion-control service";
|
|
|
|
settings = mkOption {
|
|
|
|
default = { };
|
|
|
|
type = toml.type;
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
path_db = {
|
2024-06-28 23:16:36 +03:00
|
|
|
connection = "/run/scion-control/control.path.db";
|
2024-03-24 21:03:03 +00:00
|
|
|
};
|
|
|
|
log.console = {
|
|
|
|
level = "info";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
scion-control configuration. Refer to
|
|
|
|
<https://docs.scion.org/en/latest/manuals/common.html>
|
|
|
|
for details on supported values.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.scion-control = {
|
|
|
|
description = "SCION Control Service";
|
|
|
|
after = [
|
|
|
|
"network-online.target"
|
|
|
|
"scion-dispatcher.service"
|
|
|
|
];
|
|
|
|
wants = [
|
|
|
|
"network-online.target"
|
|
|
|
"scion-dispatcher.service"
|
|
|
|
];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
Group = if (config.services.scion.scion-dispatcher.enable == true) then "scion" else null;
|
2024-07-19 01:30:10 +01:00
|
|
|
ExecStart = "${globalCfg.package}/bin/scion-control --config ${configFile}";
|
2024-03-24 21:03:03 +00:00
|
|
|
DynamicUser = true;
|
|
|
|
Restart = "on-failure";
|
|
|
|
BindPaths = [ "/dev/shm:/run/shm" ];
|
2024-07-02 14:57:38 +01:00
|
|
|
${if globalCfg.stateless then "RuntimeDirectory" else "StateDirectory"} = "scion-control";
|
2024-03-24 21:03:03 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|