about summary refs log tree commit diff
path: root/nixos/modules/services/networking/scion/scion-daemon.nix
blob: 8528bec1d52eb0bc69523908245a68d47990e53b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.scion.scion-daemon;
  toml = pkgs.formats.toml { };
  defaultConfig = {
    general = {
      id = "sd";
      config_dir = "/etc/scion";
      reconnect_to_dispatcher = true;
    };
    path_db = {
      connection = "/run/scion-daemon/sd.path.db";
    };
    trust_db = {
      connection = "/run/scion-daemon/sd.trust.db";
    };
    log.console = {
      level = "info";
    };
  };
  configFile = toml.generate "scion-daemon.toml" (recursiveUpdate defaultConfig cfg.settings);
in
{
  options.services.scion.scion-daemon = {
    enable = mkEnableOption "the scion-daemon service";
    settings = mkOption {
      default = { };
      type = toml.type;
      example = literalExpression ''
        {
          path_db = {
            connection = "/run/scion-daemon/sd.path.db";
          };
          log.console = {
            level = "info";
          };
        }
      '';
      description = ''
        scion-daemon configuration. Refer to
        <https://docs.scion.org/en/latest/manuals/common.html>
        for details on supported values.
      '';
    };
  };
  config = mkIf cfg.enable {
    systemd.services.scion-daemon = {
      description = "SCION Daemon";
      after = [ "network-online.target" "scion-dispatcher.service" ];
      wants = [ "network-online.target" "scion-dispatcher.service" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        Type = "simple";
        ExecStart = "${pkgs.scion}/bin/scion-daemon --config ${configFile}";
        Restart = "on-failure";
        DynamicUser = true;
        RuntimeDirectory = "scion-daemon";
      };
    };
  };
}