at master 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 }; 20 path_db = { 21 connection = "${connectionDir}/scion-daemon/sd.path.db"; 22 }; 23 trust_db = { 24 connection = "${connectionDir}/scion-daemon/sd.trust.db"; 25 }; 26 log.console = { 27 level = "info"; 28 }; 29 }; 30 configFile = toml.generate "scion-daemon.toml" (recursiveUpdate defaultConfig cfg.settings); 31in 32{ 33 options.services.scion.scion-daemon = { 34 enable = mkEnableOption "the scion-daemon service"; 35 settings = mkOption { 36 default = { }; 37 type = toml.type; 38 example = literalExpression '' 39 { 40 path_db = { 41 connection = "/run/scion-daemon/sd.path.db"; 42 }; 43 log.console = { 44 level = "info"; 45 }; 46 } 47 ''; 48 description = '' 49 scion-daemon configuration. Refer to 50 <https://docs.scion.org/en/latest/manuals/common.html> 51 for details on supported values. 52 ''; 53 }; 54 }; 55 config = mkIf cfg.enable { 56 systemd.services.scion-daemon = { 57 description = "SCION Daemon"; 58 after = [ 59 "network-online.target" 60 "scion-dispatcher.service" 61 ]; 62 wants = [ 63 "network-online.target" 64 "scion-dispatcher.service" 65 ]; 66 wantedBy = [ "multi-user.target" ]; 67 serviceConfig = { 68 Type = "simple"; 69 ExecStart = "${globalCfg.package}/bin/scion-daemon --config ${configFile}"; 70 Restart = "on-failure"; 71 DynamicUser = true; 72 ${if globalCfg.stateless then "RuntimeDirectory" else "StateDirectory"} = "scion-daemon"; 73 }; 74 }; 75 }; 76}