summary refs log tree commit diff
path: root/nixos/modules/services/networking/bird.nix
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2015-05-16 23:22:35 +0200
committerlassulus <lass@aidsballs.de>2015-05-19 15:42:24 +0200
commit9d07c54fa11bc577f8fc946aef9be9d059d4f40a (patch)
treee6ed5de6d8d028bd002f797d63837294593044e9 /nixos/modules/services/networking/bird.nix
parent8f648b2d14db39b73d31d23d4fcbc54eb6f9d0e0 (diff)
downloadnixpkgs-9d07c54fa11bc577f8fc946aef9be9d059d4f40a.tar
nixpkgs-9d07c54fa11bc577f8fc946aef9be9d059d4f40a.tar.gz
nixpkgs-9d07c54fa11bc577f8fc946aef9be9d059d4f40a.tar.bz2
nixpkgs-9d07c54fa11bc577f8fc946aef9be9d059d4f40a.tar.lz
nixpkgs-9d07c54fa11bc577f8fc946aef9be9d059d4f40a.tar.xz
nixpkgs-9d07c54fa11bc577f8fc946aef9be9d059d4f40a.tar.zst
nixpkgs-9d07c54fa11bc577f8fc946aef9be9d059d4f40a.zip
nixos: add bird module
patch bird to look in /var/run for birc.ctl
Diffstat (limited to 'nixos/modules/services/networking/bird.nix')
-rw-r--r--nixos/modules/services/networking/bird.nix76
1 files changed, 76 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/bird.nix b/nixos/modules/services/networking/bird.nix
new file mode 100644
index 00000000000..2fa1d6af7d2
--- /dev/null
+++ b/nixos/modules/services/networking/bird.nix
@@ -0,0 +1,76 @@
+{ config, lib, pkgs, ... }:
+
+let
+  inherit (lib) mkEnableOption mkIf mkOption singleton types;
+  inherit (pkgs) bird;
+  cfg = config.services.bird;
+
+  configFile = pkgs.writeText "bird.conf" ''
+    ${cfg.config}
+  '';
+in
+
+{
+
+  ###### interface
+
+  options = {
+
+    services.bird = {
+
+      enable = mkEnableOption "BIRD Internet Routing Daemon";
+
+      config = mkOption {
+        type = types.string;
+        description = ''
+          BIRD Internet Routing Daemon configuration file.
+          http://bird.network.cz/?get_doc&f=bird-3.html
+        '';
+      };
+
+      user = mkOption {
+        type = types.string;
+        default = "ircd";
+        description = ''
+          BIRD Internet Routing Daemon user.
+        '';
+      };
+
+      group = mkOption {
+        type = types.string;
+        default = "ircd";
+        description = ''
+          BIRD Internet Routing Daemon group.
+        '';
+      };
+
+    };
+
+  };
+
+
+  ###### implementation
+
+  config = mkIf cfg.enable {
+
+    users.extraUsers = singleton {
+      name = cfg.user;
+      description = "BIRD Internet Routing Daemon user";
+      uid = config.ids.uids.bird;
+      group = cfg.group;
+    };
+
+    users.extraGroups = singleton {
+      name = cfg.group;
+      gid = config.ids.gids.bird;
+    };
+
+    systemd.services.bird = {
+      description = "BIRD Internet Routing Daemon";
+      wantedBy = [ "multi-user.target" ];
+      serviceConfig = {
+        ExecStart   = "${bird}/bin/bird -d -c ${configFile} -s /var/run/bird.ctl -u ${cfg.user} -g ${cfg.group}";
+      };
+    };
+  };
+}