vuls: init at 0.27.0
[NixPkgs.git] / nixos / modules / services / networking / gobgpd.nix
blob79f1adf4e314d8dedb4380cdfbc98843562d792f
1 { config, pkgs, lib, ... }:
2 let
3   cfg = config.services.gobgpd;
4   format = pkgs.formats.toml { };
5   confFile = format.generate "gobgpd.conf" cfg.settings;
6 in {
7   options.services.gobgpd = {
8     enable = lib.mkEnableOption "GoBGP Routing Daemon";
10     settings = lib.mkOption {
11       type = format.type;
12       default = { };
13       description = ''
14         GoBGP configuration. Refer to
15         <https://github.com/osrg/gobgp#documentation>
16         for details on supported values.
17       '';
18       example = lib.literalExpression ''
19         {
20           global = {
21             config = {
22               as = 64512;
23               router-id = "192.168.255.1";
24             };
25           };
26           neighbors = [
27             {
28               config = {
29                 neighbor-address = "10.0.255.1";
30                 peer-as = 65001;
31               };
32             }
33             {
34               config = {
35                 neighbor-address = "10.0.255.2";
36                 peer-as = 65002;
37               };
38             }
39           ];
40         }
41       '';
42     };
43   };
45   config = lib.mkIf cfg.enable {
46     environment.systemPackages = [ pkgs.gobgpd ];
47     systemd.services.gobgpd = {
48       wantedBy = [ "multi-user.target" ];
49       after = [ "network.target" ];
50       description = "GoBGP Routing Daemon";
51       serviceConfig = {
52         Type = "notify";
53         ExecStartPre = "${pkgs.gobgpd}/bin/gobgpd -f ${confFile} -d";
54         ExecStart = "${pkgs.gobgpd}/bin/gobgpd -f ${confFile} --sdnotify";
55         ExecReload = "${pkgs.gobgpd}/bin/gobgpd -r";
56         DynamicUser = true;
57         AmbientCapabilities = "cap_net_bind_service";
58       };
59     };
60   };