Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/bird: rename bird2 to bird, switch to bird3 by default #366190

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -182,6 +182,8 @@

- `linuxPackages.nvidiaPackages.dc_520` has been removed since it is marked broken and there are better newer alternatives.

- `services.bird2` has been renamed to `services.bird` and the default bird package has been switched to `bird3`. `bird2` can still be choosen via the `services.bird.package` option.

- `programs.less.lessopen` is now null by default. To restore the previous behaviour, set it to `''|${lib.getExe' pkgs.lesspipe "lesspipe.sh"} %s''`.

- `hardware.pulseaudio` has been renamed to `services.pulseaudio`. The deprecated option names will continue to work, but causes a warning.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ in
};
serviceOpts = {
serviceConfig = {
SupplementaryGroups = singleton (if cfg.birdVersion == 1 then "bird" else "bird2");
SupplementaryGroups = "bird";
ExecStart = ''
${pkgs.prometheus-bird-exporter}/bin/bird_exporter \
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/bird-lg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ in
groups."bird-lg" = lib.mkIf (cfg.group == "bird-lg") { };
users."bird-lg" = lib.mkIf (cfg.user == "bird-lg") {
description = "Bird Looking Glass user";
extraGroups = lib.optionals (config.services.bird2.enable) [ "bird2" ];
extraGroups = lib.optionals (config.services.bird.enable) [ "bird" ];
group = cfg.group;
isSystemUser = true;
};
Expand Down
49 changes: 28 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 "bird3" { };
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,38 @@ in
};

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use mkRenamedOptionModule and make package depending on stateVersion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using mkRenamedOptionModule is arguable but it can not give a custom user message.
Depending on stateVersion is strange as the user has to handle the change anyways and the added package option seems to be enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because its not renamed but actually changed in this case. and having a general services.bird makes more sense in the first place as thats the general practice on nixpkgs in general, this is just bikeshedding imo and preventing useful things from happening on nixpkgs.

"Use services.bird instead. bird3 is the new default bird package. You can choose to remain with bird2 by setting the service.bird.package option."
)
(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 = "${lib.getExe' cfg.package "bird"} -c /etc/bird/bird.conf";
ExecReload = "${lib.getExe' cfg.package "birdc"} configure";
ExecStop = "${lib.getExe' cfg.package "birdc"} down";
RuntimeDirectory = "bird";
CapabilityBoundingSet = caps;
AmbientCapabilities = caps;
Expand All @@ -112,12 +115,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 ];
};
}
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/birdwatcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ in

[bird]
listen = "0.0.0.0:29184"
config = "/etc/bird/bird2.conf"
config = "/etc/bird/bird.conf"
birdc = "''${pkgs.bird}/bin/birdc"
ttl = 5 # time to live (in minutes) for caching of cli output

Expand Down
16 changes: 8 additions & 8 deletions nixos/tests/bird.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let
inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
inherit (pkgs.lib) optionalString;

makeBird2Host =
makeBirdHost =
hostId:
{ pkgs, ... }:
{
Expand All @@ -32,7 +32,7 @@ let
networkConfig.Address = "10.0.0.${hostId}/24";
};

services.bird2 = {
services.bird = {
enable = true;

config = ''
Expand Down Expand Up @@ -107,17 +107,17 @@ let
};
in
makeTest {
name = "bird2";
name = "bird";

nodes.host1 = makeBird2Host "1";
nodes.host2 = makeBird2Host "2";
nodes.host1 = makeBirdHost "1";
nodes.host2 = makeBirdHost "2";

testScript = ''
start_all()

host1.wait_for_unit("bird2.service")
host2.wait_for_unit("bird2.service")
host1.succeed("systemctl reload bird2.service")
host1.wait_for_unit("bird.service")
host2.wait_for_unit("bird.service")
host1.succeed("systemctl reload bird.service")

with subtest("Waiting for advertised IPv4 routes"):
host1.wait_until_succeeds("ip --json r | jq -e 'map(select(.dst == \"10.10.0.2\")) | any'")
Expand Down
6 changes: 3 additions & 3 deletions nixos/tests/birdwatcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ makeTest {
nodes = {
host1 = {
environment.systemPackages = with pkgs; [ jq ];
services.bird2 = {
services.bird = {
enable = true;
config = ''
log syslog all;
Expand Down Expand Up @@ -71,7 +71,7 @@ makeTest {
filter_fields = []
[bird]
listen = "0.0.0.0:29184"
config = "/etc/bird/bird2.conf"
config = "/etc/bird/bird.conf"
birdc = "${pkgs.bird}/bin/birdc"
ttl = 5 # time to live (in minutes) for caching of cli output
[parser]
Expand All @@ -89,7 +89,7 @@ makeTest {
testScript = ''
start_all()

host1.wait_for_unit("bird2.service")
host1.wait_for_unit("bird.service")
host1.wait_for_unit("birdwatcher.service")
host1.wait_for_open_port(29184)
host1.succeed("curl http://[::]:29184/status | jq -r .status.message | grep 'Daemon is up and running'")
Expand Down
4 changes: 2 additions & 2 deletions nixos/tests/fastnetmon-advanced.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{ ... }:
{
networking.firewall.allowedTCPPorts = [ 179 ];
services.bird2 = {
services.bird = {
enable = true;
config = ''
router id 192.168.1.1;
Expand Down Expand Up @@ -59,7 +59,7 @@
''
start_all()
fnm.wait_for_unit("fastnetmon.service")
bird.wait_for_unit("bird2.service")
bird.wait_for_unit("bird.service")

fnm.wait_until_succeeds('journalctl -eu fastnetmon.service | grep "BGP daemon restarted correctly"')
fnm.wait_until_succeeds("journalctl -eu gobgp.service | grep BGP_FSM_OPENCONFIRM")
Expand Down
4 changes: 2 additions & 2 deletions nixos/tests/prometheus-exporters.nix
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ let
enable = true;
};
metricProvider = {
services.bird2.enable = true;
services.bird2.config = ''
services.bird.enable = true;
services.bird.config = ''
router id 127.0.0.1;

protocol kernel MyObviousTestString {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
version = "2.16.1";

src = fetchurl {
url = "ftp://bird.network.cz/pub/bird/${pname}-${version}.tar.gz";
url = "https://bird.network.cz/download/bird-${version}.tar.gz";
hash = "sha256-9uWcvMrKYmaK6gIGhyS9QnuexEnH4PD8VoFQOYjHNbQ=";
};

Expand Down Expand Up @@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
meta = with lib; {
changelog = "https://gitlab.nic.cz/labs/bird/-/blob/v${version}/NEWS";
description = "BIRD Internet Routing Daemon";
homepage = "http://bird.network.cz";
homepage = "https://bird.network.cz";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ herbetom ];
platforms = platforms.linux;
Expand Down
6 changes: 6 additions & 0 deletions pkgs/by-name/bi/bird3/dont-create-sysconfdir-2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--- a/Makefile.in
+++ b/Makefile.in
@@ -165,2 +165,2 @@
install: all
- $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/$(runstatedir)
+ $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir)
51 changes: 51 additions & 0 deletions pkgs/by-name/bi/bird3/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
lib,
stdenv,
fetchurl,
flex,
bison,
readline,
libssh,
nixosTests,
}:

stdenv.mkDerivation rec {
pname = "bird";
version = "3.0.1";

src = fetchurl {
url = "https://bird.network.cz/download/bird-${version}.tar.gz";
hash = "sha256-iGhAPKqE4lVLtuYK2+fGV+e7fErEGRDjmPNeI2upD6E=";
};

nativeBuildInputs = [
flex
bison
];
buildInputs = [
readline
libssh
];

patches = [
./dont-create-sysconfdir-2.patch
];

CPP = "${stdenv.cc.targetPrefix}cpp -E";

configureFlags = [
"--localstatedir=/var"
"--runstatedir=/run/bird"
];

passthru.tests = nixosTests.bird;

meta = with lib; {
changelog = "https://gitlab.nic.cz/labs/bird/-/blob/v${version}/NEWS";
description = "BIRD Internet Routing Daemon";
homepage = "https://bird.network.cz";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ herbetom ];
platforms = platforms.linux;
};
}
2 changes: 1 addition & 1 deletion pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ mapAliases {
bibata-extra-cursors = throw "bibata-cursors has been removed as it was broken"; # Added 2024-07-15
bitcoin-unlimited = throw "bitcoin-unlimited has been removed as it was broken and unmaintained"; # Added 2024-07-15
bitcoind-unlimited = throw "bitcoind-unlimited has been removed as it was broken and unmaintained"; # Added 2024-07-15
bird2 = bird; # Added 2022-02-21
bird = bird3; # Added 2025-01-11
bisq-desktop = throw "bisq-desktop has been removed because OpenJFX 11 was removed"; # Added 2024-11-17
bitwarden = bitwarden-desktop; # Added 2024-02-25
blender-with-packages = args:
Expand Down