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