From 9d07c54fa11bc577f8fc946aef9be9d059d4f40a Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 16 May 2015 23:22:35 +0200 Subject: [PATCH] nixos: add bird module patch bird to look in /var/run for birc.ctl --- nixos/modules/misc/ids.nix | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/networking/bird.nix | 76 +++++++++++++++++++ pkgs/servers/bird/default.nix | 8 ++ .../servers/bird/dont-create-sysconfdir.patch | 13 ++++ 5 files changed, 100 insertions(+) create mode 100644 nixos/modules/services/networking/bird.nix create mode 100644 pkgs/servers/bird/dont-create-sysconfdir.patch diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 0039ca74ba8..3f45f78a9d8 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -217,6 +217,7 @@ lambdabot = 191; asterisk = 192; plex = 193; + bird = 195; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -412,6 +413,7 @@ #asterisk = 192; # unused plex = 193; sabnzbd = 194; + bird = 195; # When adding a gid, make sure it doesn't match an existing # uid. Users and groups with the same name should have equal diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 043b0470edf..bef3f7f2fe7 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -252,6 +252,7 @@ ./services/networking/atftpd.nix ./services/networking/avahi-daemon.nix ./services/networking/bind.nix + ./services/networking/bird.nix ./services/networking/bitlbee.nix ./services/networking/btsync.nix ./services/networking/charybdis.nix 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}"; + }; + }; + }; +} diff --git a/pkgs/servers/bird/default.nix b/pkgs/servers/bird/default.nix index 9b17551a8cb..c13ad64fca3 100644 --- a/pkgs/servers/bird/default.nix +++ b/pkgs/servers/bird/default.nix @@ -10,6 +10,14 @@ stdenv.mkDerivation rec { buildInputs = [ flex bison readline ]; + patches = [ + ./dont-create-sysconfdir.patch + ]; + + configureFlags = [ + "--localstatedir /var" + ]; + meta = { description = "BIRD Internet Routing Daemon"; homepage = http://bird.network.cz; diff --git a/pkgs/servers/bird/dont-create-sysconfdir.patch b/pkgs/servers/bird/dont-create-sysconfdir.patch new file mode 100644 index 00000000000..0a11c8a2a8d --- /dev/null +++ b/pkgs/servers/bird/dont-create-sysconfdir.patch @@ -0,0 +1,13 @@ +diff --git a/tools/Makefile.in b/tools/Makefile.in +index 062ba91..4fd7453 100644 +--- a/tools/Makefile.in ++++ b/tools/Makefile.in +@@ -68,7 +68,7 @@ tags: + cd $(srcdir) ; etags -lc `find $(static-dirs) $(addprefix $(objdir)/,$(dynamic-dirs)) $(client-dirs) -name *.[chY]` + + install: all +- $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/@runtimedir@ ++ $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) + $(INSTALL_PROGRAM) $(exedir)/bird $(DESTDIR)/$(sbindir)/bird@SUFFIX@ + $(INSTALL_PROGRAM) $(exedir)/birdcl $(DESTDIR)/$(sbindir)/birdcl@SUFFIX@ + if test -n "@CLIENT@" ; then \