@@ -0,0 +1,76 @@
1+{ config, lib, pkgs, ... }:
2+
3+let
4+ inherit (lib) mkEnableOption mkIf mkOption singleton types;
5+ inherit (pkgs) bird;
6+ cfg = config.services.bird;
7+
8+ configFile = pkgs.writeText "bird.conf" ''
9+ ${cfg.config}
10+ '';
11+in
12+
13+{
14+
15+ ###### interface
16+
17+ options = {
18+
19+ services.bird = {
20+
21+ enable = mkEnableOption "BIRD Internet Routing Daemon";
22+
23+ config = mkOption {
24+ type = types.string;
25+ description = ''
26+ BIRD Internet Routing Daemon configuration file.
27+ http://bird.network.cz/?get_doc&f=bird-3.html
28+ '';
29+ };
30+
31+ user = mkOption {
32+ type = types.string;
33+ default = "ircd";
34+ description = ''
35+ BIRD Internet Routing Daemon user.
36+ '';
37+ };
38+
39+ group = mkOption {
40+ type = types.string;
41+ default = "ircd";
42+ description = ''
43+ BIRD Internet Routing Daemon group.
44+ '';
45+ };
46+
47+ };
48+
49+ };
50+
51+
52+ ###### implementation
53+
54+ config = mkIf cfg.enable {
55+
56+ users.extraUsers = singleton {
57+ name = cfg.user;
58+ description = "BIRD Internet Routing Daemon user";
59+ uid = config.ids.uids.bird;
60+ group = cfg.group;
61+ };
62+
63+ users.extraGroups = singleton {
64+ name = cfg.group;
65+ gid = config.ids.gids.bird;
66+ };
67+
68+ systemd.services.bird = {
69+ description = "BIRD Internet Routing Daemon";
70+ wantedBy = [ "multi-user.target" ];
71+ serviceConfig = {
72+ ExecStart = "${bird}/bin/bird -d -c ${configFile} -s /var/run/bird.ctl -u ${cfg.user} -g ${cfg.group}";
73+ };
74+ };
75+ };
76+}