1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-21 17:01:10 +03:00
nixpkgs/nixos/modules/services/networking/scion/scion-control.nix

83 lines
2.1 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
...
}:
2024-03-24 21:03:03 +00:00
with lib;
let
globalCfg = config.services.scion;
2024-03-24 21:03:03 +00:00
cfg = config.services.scion.scion-control;
toml = pkgs.formats.toml { };
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 = {
connection = "${connectionDir}/scion-control/control.beacon.db";
2024-03-24 21:03:03 +00:00
};
path_db = {
connection = "${connectionDir}/scion-control/control.path.db";
2024-03-24 21:03:03 +00:00
};
trust_db = {
connection = "${connectionDir}/scion-control/control.trust.db";
2024-03-24 21:03:03 +00:00
};
log.console = {
level = "info";
};
};
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";
2024-03-24 21:03:03 +00:00
settings = mkOption {
default = { };
type = toml.type;
example = literalExpression ''
{
path_db = {
connection = "/run/scion-control/control.path.db";
2024-03-24 21:03:03 +00:00
};
log.console = {
level = "info";
};
}
'';
description = ''
2024-03-24 21:03:03 +00:00
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"
];
2024-03-24 21:03:03 +00:00
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
Group = if (config.services.scion.scion-dispatcher.enable == true) then "scion" else null;
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" ];
${if globalCfg.stateless then "RuntimeDirectory" else "StateDirectory"} = "scion-control";
2024-03-24 21:03:03 +00:00
};
};
};
}