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