at 24.11-pre 1.9 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.scion.scion-control; 7 toml = pkgs.formats.toml { }; 8 defaultConfig = { 9 general = { 10 id = "cs"; 11 config_dir = "/etc/scion"; 12 reconnect_to_dispatcher = true; 13 }; 14 beacon_db = { 15 connection = "/var/lib/scion-control/control.beacon.db"; 16 }; 17 path_db = { 18 connection = "/var/lib/scion-control/control.path.db"; 19 }; 20 trust_db = { 21 connection = "/var/lib/scion-control/control.trust.db"; 22 }; 23 log.console = { 24 level = "info"; 25 }; 26 }; 27 configFile = toml.generate "scion-control.toml" (defaultConfig // cfg.settings); 28in 29{ 30 options.services.scion.scion-control = { 31 enable = mkEnableOption "the scion-control service"; 32 settings = mkOption { 33 default = { }; 34 type = toml.type; 35 example = literalExpression '' 36 { 37 path_db = { 38 connection = "/var/lib/scion-control/control.path.db"; 39 }; 40 log.console = { 41 level = "info"; 42 }; 43 } 44 ''; 45 description = '' 46 scion-control configuration. Refer to 47 <https://docs.scion.org/en/latest/manuals/common.html> 48 for details on supported values. 49 ''; 50 }; 51 }; 52 config = mkIf cfg.enable { 53 systemd.services.scion-control = { 54 description = "SCION Control Service"; 55 after = [ "network-online.target" "scion-dispatcher.service" ]; 56 wants = [ "network-online.target" "scion-dispatcher.service" ]; 57 wantedBy = [ "multi-user.target" ]; 58 serviceConfig = { 59 Type = "simple"; 60 Group = if (config.services.scion.scion-dispatcher.enable == true) then "scion" else null; 61 ExecStart = "${pkgs.scion}/bin/scion-control --config ${configFile}"; 62 DynamicUser = true; 63 Restart = "on-failure"; 64 BindPaths = [ "/dev/shm:/run/shm" ]; 65 StateDirectory = "scion-control"; 66 }; 67 }; 68 }; 69}