Skip to content

Commit

Permalink
nixos/bird: rename bird2 to bird
Browse files Browse the repository at this point in the history
This is done in view of the Release of Bird 3.

This also adds a services.bird.package option to enable easier overwrites.
  • Loading branch information
herbetom committed Dec 18, 2024
1 parent 4989a24 commit d338013
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@

- `networking.wireguard` now has an optional networkd backend. It is enabled by default when `networking.useNetworkd` is enabled, and it can be enabled alongside scripted networking with `networking.wireguard.useNetworkd`. Some `networking.wireguard` options have slightly different behavior with the networkd and script-based backends, documented in each option.

- `services.bird2` was renamed to `services.bird`.

- `services.avahi.ipv6` now defaults to true.

- `bind.cacheNetworks` now only controls access for recursive queries, where it previously controlled access for all queries.
Expand Down
47 changes: 26 additions & 21 deletions nixos/modules/services/networking/bird.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let
types
;

cfg = config.services.bird2;
cfg = config.services.bird;
caps = [
"CAP_NET_ADMIN"
"CAP_NET_BIND_SERVICE"
Expand All @@ -24,8 +24,9 @@ in
{
###### interface
options = {
services.bird2 = {
services.bird = {
enable = mkEnableOption "BIRD Internet Routing Daemon";
package = lib.mkPackageOption pkgs "bird" { };
config = mkOption {
type = types.lines;
description = ''
Expand All @@ -37,7 +38,7 @@ in
type = types.bool;
default = true;
description = ''
Whether bird2 should be automatically reloaded when the configuration changes.
Whether bird should be automatically reloaded when the configuration changes.
'';
};
checkConfig = mkOption {
Expand All @@ -58,7 +59,7 @@ in
'';
description = ''
Commands to execute before the config file check. The file to be checked will be
available as `bird2.conf` in the current directory.
available as `bird.conf` in the current directory.
Files created with this option will not be available at service runtime, only during
build time checking.
Expand All @@ -68,36 +69,36 @@ in
};

imports = [
(lib.mkRemovedOptionModule [ "services" "bird" ] "Use services.bird2 instead")
(lib.mkRemovedOptionModule [ "services" "bird6" ] "Use services.bird2 instead")
(lib.mkRemovedOptionModule [ "services" "bird2" ] "Use services.bird instead")
(lib.mkRemovedOptionModule [ "services" "bird6" ] "Use services.bird instead")
];

###### implementation
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.bird ];
environment.systemPackages = [ cfg.package ];

environment.etc."bird/bird2.conf".source = pkgs.writeTextFile {
name = "bird2";
environment.etc."bird/bird.conf".source = pkgs.writeTextFile {
name = "bird";
text = cfg.config;
checkPhase = optionalString cfg.checkConfig ''
ln -s $out bird2.conf
ln -s $out bird.conf
${cfg.preCheckConfig}
${pkgs.buildPackages.bird}/bin/bird -d -p -c bird2.conf
${pkgs.buildPackages.bird}/bin/bird -d -p -c bird.conf
'';
};

systemd.services.bird2 = {
systemd.services.bird = {
description = "BIRD Internet Routing Daemon";
wantedBy = [ "multi-user.target" ];
reloadTriggers = lib.optional cfg.autoReload config.environment.etc."bird/bird2.conf".source;
reloadTriggers = lib.optional cfg.autoReload config.environment.etc."bird/bird.conf".source;
serviceConfig = {
Type = "forking";
Restart = "on-failure";
User = "bird2";
Group = "bird2";
ExecStart = "${pkgs.bird}/bin/bird -c /etc/bird/bird2.conf";
ExecReload = "${pkgs.bird}/bin/birdc configure";
ExecStop = "${pkgs.bird}/bin/birdc down";
User = "bird";
Group = "bird";
ExecStart = "${cfg.package}/bin/bird -c /etc/bird/bird.conf";
ExecReload = "${cfg.package}/bin/birdc configure";
ExecStop = "${cfg.package}/bin/birdc down";
RuntimeDirectory = "bird";
CapabilityBoundingSet = caps;
AmbientCapabilities = caps;
Expand All @@ -112,12 +113,16 @@ in
};
};
users = {
users.bird2 = {
users.bird = {
description = "BIRD Internet Routing Daemon user";
group = "bird2";
group = "bird";
isSystemUser = true;
};
groups.bird2 = { };
groups.bird = { };
};
};

meta = {
maintainers = with lib.maintainers; [ herbetom ];
};
}

0 comments on commit d338013

Please sign in to comment.