about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/networking/scion/scion-router.nix
blob: cbe83c6dbf8d1f8ea81015a0ad82b328aec2cc09 (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
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.scion.scion-router;
  toml = pkgs.formats.toml { };
  defaultConfig = {
    general = {
      id = "br";
      config_dir = "/etc/scion";
    };
  };
  configFile = toml.generate "scion-router.toml" (defaultConfig // cfg.settings);
in
{
  options.services.scion.scion-router = {
    enable = mkEnableOption (lib.mdDoc "the scion-router service");
    settings = mkOption {
      default = { };
      type = toml.type;
      example = literalExpression ''
        {
          general.id = "br";
        }
      '';
      description = lib.mdDoc ''
        scion-router configuration. Refer to
        <https://docs.scion.org/en/latest/manuals/common.html>
        for details on supported values.
      '';
    };
  };
  config = mkIf cfg.enable {
    systemd.services.scion-router = {
      description = "SCION Router";
      after = [ "network-online.target" ];
      wants = [ "network-online.target" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        Type = "simple";
        ExecStart = "${pkgs.scion}/bin/scion-router --config ${configFile}";
        Restart = "on-failure";
        DynamicUser = true;
        StateDirectory = "scion-router";
      };
    };
  };
}