diff options
author | Yuya Kusakabe <yuya.kusakabe@gmail.com> | 2021-04-09 14:57:11 +0000 |
---|---|---|
committer | Yuya Kusakabe <yuya.kusakabe@gmail.com> | 2021-04-09 14:57:11 +0000 |
commit | 45cffe79850355b3b3d0d8dd96545067514d13d7 (patch) | |
tree | 58dd78b2b038677b2afa48bfe854bacb934ca33e | |
parent | 9a2af3baf2a27c80e415e868ae9e30d78c883261 (diff) | |
download | nixpkgs-45cffe79850355b3b3d0d8dd96545067514d13d7.tar nixpkgs-45cffe79850355b3b3d0d8dd96545067514d13d7.tar.gz nixpkgs-45cffe79850355b3b3d0d8dd96545067514d13d7.tar.bz2 nixpkgs-45cffe79850355b3b3d0d8dd96545067514d13d7.tar.lz nixpkgs-45cffe79850355b3b3d0d8dd96545067514d13d7.tar.xz nixpkgs-45cffe79850355b3b3d0d8dd96545067514d13d7.tar.zst nixpkgs-45cffe79850355b3b3d0d8dd96545067514d13d7.zip |
nixos/gobpgd: init
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/networking/gobgpd.nix | 64 |
2 files changed, 65 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 4a63a09ab84..09dda2ada6d 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -671,6 +671,7 @@ ./services/networking/gnunet.nix ./services/networking/go-neb.nix ./services/networking/go-shadowsocks2.nix + ./services/networking/gobgpd.nix ./services/networking/gogoclient.nix ./services/networking/gvpe.nix ./services/networking/hans.nix diff --git a/nixos/modules/services/networking/gobgpd.nix b/nixos/modules/services/networking/gobgpd.nix new file mode 100644 index 00000000000..d3b03471f4e --- /dev/null +++ b/nixos/modules/services/networking/gobgpd.nix @@ -0,0 +1,64 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.gobgpd; + format = pkgs.formats.toml { }; + confFile = format.generate "gobgpd.conf" cfg.settings; +in { + options.services.gobgpd = { + enable = mkEnableOption "GoBGP Routing Daemon"; + + settings = mkOption { + type = format.type; + default = { }; + description = '' + GoBGP configuration. Refer to + <link xlink:href="https://github.com/osrg/gobgp#documentation"/> + for details on supported values. + ''; + example = literalExample '' + { + global = { + config = { + as = 64512; + router-id = "192.168.255.1"; + }; + }; + neighbors = [ + { + config = { + neighbor-address = "10.0.255.1"; + peer-as = 65001; + }; + } + { + config = { + neighbor-address = "10.0.255.2"; + peer-as = 65002; + }; + } + ]; + } + ''; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ pkgs.gobgpd ]; + systemd.services.gobgpd = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + description = "GoBGP Routing Daemon"; + serviceConfig = { + Type = "notify"; + ExecStartPre = "${pkgs.gobgpd}/bin/gobgpd -f ${confFile} -d"; + ExecStart = "${pkgs.gobgpd}/bin/gobgpd -f ${confFile} --sdnotify"; + ExecReload = "${pkgs.gobgpd}/bin/gobgpd -r"; + DynamicUser = true; + AmbientCapabilities = "cap_net_bind_service"; + }; + }; + }; +} |