From 93c0489bdc4d4477ee51a1ec2a072c466b537296 Mon Sep 17 00:00:00 2001 From: Markus Theil Date: Fri, 21 Jul 2023 14:40:07 +0200 Subject: [PATCH 1/4] frr: fix cross compilation x86-64 -> aarch64 Signed-off-by: Markus Theil --- pkgs/servers/frr/clippy-helper.nix | 59 ++++++++++++++++++++++++++++++ pkgs/servers/frr/default.nix | 22 ++++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 pkgs/servers/frr/clippy-helper.nix diff --git a/pkgs/servers/frr/clippy-helper.nix b/pkgs/servers/frr/clippy-helper.nix new file mode 100644 index 000000000000..9e554d4e17e6 --- /dev/null +++ b/pkgs/servers/frr/clippy-helper.nix @@ -0,0 +1,59 @@ +{ lib +, stdenv +, frr_source +, frr_version + +# build time +, autoreconfHook +, flex +, bison +, pkg-config +, libelf +, perl +, python3 + +}: + +stdenv.mkDerivation rec { + pname = "frr-clippy-helper"; + version = frr_version; + + src = frr_source; + + nativeBuildInputs = [ + autoreconfHook + bison + flex + perl + pkg-config + ]; + + buildInputs = [ + libelf + python3 + ]; + + configureFlags = [ + "--enable-clippy-only" + ]; + + installPhase = '' + mkdir -p $out/bin + cp lib/clippy $out/bin + ''; + + enableParallelBuilding = true; + + meta = with lib; { + homepage = "https://frrouting.org/"; + description = "FRR routing daemon suite: CLI helper tool clippy"; + longDescription = '' + This small tool is used to support generating CLI code for FRR. It is split out here, + to support cross-compiling, because it needs to be compiled with the build system toolchain + and not the target host one. + ''; + license = with licenses; [ gpl2Plus lgpl21Plus ]; + maintainers = with maintainers; [ thillux ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/servers/frr/default.nix b/pkgs/servers/frr/default.nix index f50e3c0b2a8c..9542e921c5fb 100644 --- a/pkgs/servers/frr/default.nix +++ b/pkgs/servers/frr/default.nix @@ -9,6 +9,7 @@ , perl , pkg-config , texinfo +, buildPackages # runtime , c-ares @@ -28,8 +29,13 @@ # tests , nettools , nixosTests + +# options +, snmpSupport ? true }: +assert snmpSupport -> stdenv.buildPlatform.canExecute stdenv.hostPlatform; + stdenv.mkDerivation rec { pname = "frr"; version = "8.5.2"; @@ -57,7 +63,6 @@ stdenv.mkDerivation rec { libelf libunwind libyang - net-snmp openssl pam pcre2 @@ -66,21 +71,34 @@ stdenv.mkDerivation rec { rtrlib ] ++ lib.optionals stdenv.isLinux [ libcap + ] ++ lib.optionals snmpSupport [ + net-snmp ]; + # otherwise in cross-compilation: "configure: error: no working python version found" + depsBuildBuild = [ + buildPackages.python3 + ]; + + # cross-compiling: clippy is compiled with the build host toolchain, split it out to ease + # navigation in dependency hell + clippy-helper = buildPackages.callPackage ./clippy-helper.nix { frr_version = version; frr_source=src; }; + configureFlags = [ + "--disable-silent-rules" "--disable-exampledir" "--enable-configfile-mask=0640" "--enable-group=frr" "--enable-logfile-mask=0640" "--enable-multipath=64" - "--enable-snmp" + (lib.strings.enableFeature snmpSupport "snmp") "--enable-user=frr" "--enable-vty-group=frrvty" "--localstatedir=/run/frr" "--sbindir=$(out)/libexec/frr" "--sysconfdir=/etc/frr" "--enable-rpki" + "--with-clippy=${clippy-helper}/bin/clippy" ]; postPatch = '' From 6730140c87d7a049712e0fa150625eba07f0aa39 Mon Sep 17 00:00:00 2001 From: Markus Theil Date: Fri, 21 Jul 2023 15:40:10 +0200 Subject: [PATCH 2/4] frr: add config options for minimalization and advanced networking Signed-off-by: Markus Theil --- pkgs/servers/frr/default.nix | 80 ++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/pkgs/servers/frr/default.nix b/pkgs/servers/frr/default.nix index 9542e921c5fb..f1b2afc7884b 100644 --- a/pkgs/servers/frr/default.nix +++ b/pkgs/servers/frr/default.nix @@ -30,8 +30,45 @@ , nettools , nixosTests -# options +# general options , snmpSupport ? true +, rpkiSupport ? true +, numMultipath ? 64 +, watchfrrSupport ? true +, cumulusSupport ? false +, datacenterSupport ? true +, rtadvSupport ? true +, irdpSupport ? true +, routeReplacementSupport ? true + +# routing daemon options +, bgpdSupport ? true +, ripdSupport ? true +, ripngdSupport ? true +, ospfdSupport ? true +, ospf6dSupport ? true +, ldpdSupport ? true +, nhrpdSupport ? true +, eigrpdSupport ? true +, babeldSupport ? true +, isisdSupport ? true +, pimdSupport ? true +, pim6dSupport ? true +, sharpdSupport ? true +, fabricdSupport ? true +, vrrpdSupport ? true +, pathdSupport ? true +, bfddSupport ? true +, pbrdSupport ? true +, staticdSupport ? true + +# BGP options +, bgpAnnounce ? true +, bgpBmp ? true +, bgpVnc ? true + +# OSPF options +, ospfApi ? true }: assert snmpSupport -> stdenv.buildPlatform.canExecute stdenv.hostPlatform; @@ -90,15 +127,50 @@ stdenv.mkDerivation rec { "--enable-configfile-mask=0640" "--enable-group=frr" "--enable-logfile-mask=0640" - "--enable-multipath=64" - (lib.strings.enableFeature snmpSupport "snmp") + "--enable-multipath=${toString numMultipath}" "--enable-user=frr" "--enable-vty-group=frrvty" "--localstatedir=/run/frr" "--sbindir=$(out)/libexec/frr" "--sysconfdir=/etc/frr" - "--enable-rpki" "--with-clippy=${clippy-helper}/bin/clippy" + # general options + (lib.strings.enableFeature snmpSupport "snmp") + (lib.strings.enableFeature rpkiSupport "rpki") + (lib.strings.enableFeature watchfrrSupport "watchfrr") + (lib.strings.enableFeature rtadvSupport "rtadv") + (lib.strings.enableFeature irdpSupport "irdp") + (lib.strings.enableFeature routeReplacementSupport "rr-semantics") + # routing protocols + (lib.strings.enableFeature bgpdSupport "bgpd") + (lib.strings.enableFeature ripdSupport "ripd") + (lib.strings.enableFeature ripngdSupport "ripngd") + (lib.strings.enableFeature ospfdSupport "ospfd") + (lib.strings.enableFeature ospf6dSupport "ospf6d") + (lib.strings.enableFeature ldpdSupport "ldpd") + (lib.strings.enableFeature nhrpdSupport "nhrpd") + (lib.strings.enableFeature eigrpdSupport "eigrpd") + (lib.strings.enableFeature babeldSupport "babeld") + (lib.strings.enableFeature isisdSupport "isisd") + (lib.strings.enableFeature pimdSupport "pimd") + (lib.strings.enableFeature pim6dSupport "pim6d") + (lib.strings.enableFeature sharpdSupport "sharpd") + (lib.strings.enableFeature fabricdSupport "fabricd") + (lib.strings.enableFeature vrrpdSupport "vrrpd") + (lib.strings.enableFeature pathdSupport "pathd") + (lib.strings.enableFeature bfddSupport "bfdd") + (lib.strings.enableFeature pbrdSupport "pbrd") + (lib.strings.enableFeature staticdSupport "staticd") + # BGP options + (lib.strings.enableFeature bgpAnnounce "bgp-announce") + (lib.strings.enableFeature bgpBmp "bgp-bmp") + (lib.strings.enableFeature bgpVnc "bgp-vnc") + # OSPF options + (lib.strings.enableFeature ospfApi "ospfapi") + # Cumulus options + (lib.strings.enableFeature cumulusSupport "cumulus") + # Datacenter options + (lib.strings.enableFeature datacenterSupport "datacenter") ]; postPatch = '' From 833dd20ab2d7c366c2682e5679a573014e22531c Mon Sep 17 00:00:00 2001 From: Markus Theil Date: Fri, 21 Jul 2023 15:41:00 +0200 Subject: [PATCH 3/4] frr: add thillux to maintainer list Signed-off-by: Markus Theil --- pkgs/servers/frr/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/frr/default.nix b/pkgs/servers/frr/default.nix index f1b2afc7884b..fae9db04cf0a 100644 --- a/pkgs/servers/frr/default.nix +++ b/pkgs/servers/frr/default.nix @@ -213,7 +213,7 @@ stdenv.mkDerivation rec { private clouds. ''; license = with licenses; [ gpl2Plus lgpl21Plus ]; - maintainers = with maintainers; [ woffs ]; + maintainers = with maintainers; [ woffs thillux ]; platforms = platforms.unix; }; From e80f51a51493c00fe41bcbf35d251fcb555980d4 Mon Sep 17 00:00:00 2001 From: Markus Theil Date: Thu, 10 Aug 2023 11:26:19 +0200 Subject: [PATCH 4/4] frr: disable and warn on cross-compilation with net-snmp Signed-off-by: Markus Theil --- pkgs/servers/frr/clippy-helper.nix | 10 +++++----- pkgs/servers/frr/default.nix | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/pkgs/servers/frr/clippy-helper.nix b/pkgs/servers/frr/clippy-helper.nix index 9e554d4e17e6..bb5887bda0f3 100644 --- a/pkgs/servers/frr/clippy-helper.nix +++ b/pkgs/servers/frr/clippy-helper.nix @@ -1,9 +1,9 @@ { lib , stdenv -, frr_source -, frr_version +, frrSource +, frrVersion -# build time + # build time , autoreconfHook , flex , bison @@ -16,9 +16,9 @@ stdenv.mkDerivation rec { pname = "frr-clippy-helper"; - version = frr_version; + version = frrVersion; - src = frr_source; + src = frrSource; nativeBuildInputs = [ autoreconfHook diff --git a/pkgs/servers/frr/default.nix b/pkgs/servers/frr/default.nix index fae9db04cf0a..87fd2064a563 100644 --- a/pkgs/servers/frr/default.nix +++ b/pkgs/servers/frr/default.nix @@ -30,8 +30,15 @@ , nettools , nixosTests -# general options -, snmpSupport ? true +# FRR's configure.ac gets SNMP options by executing net-snmp-config on the build host +# This leads to compilation errors when cross compiling. +# E.g. net-snmp-config for x86_64 does not return the ARM64 paths. +# +# SNMP_LIBS="`${NETSNMP_CONFIG} --agent-libs`" +# SNMP_CFLAGS="`${NETSNMP_CONFIG} --base-cflags`" +, snmpSupport ? stdenv.buildPlatform.canExecute stdenv.hostPlatform + +# other general options besides snmp support , rpkiSupport ? true , numMultipath ? 64 , watchfrrSupport ? true @@ -71,7 +78,8 @@ , ospfApi ? true }: -assert snmpSupport -> stdenv.buildPlatform.canExecute stdenv.hostPlatform; +lib.warnIf (!(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) + "cannot enable SNMP support due to cross-compilation issues with net-snmp-config" stdenv.mkDerivation rec { pname = "frr"; @@ -119,7 +127,7 @@ stdenv.mkDerivation rec { # cross-compiling: clippy is compiled with the build host toolchain, split it out to ease # navigation in dependency hell - clippy-helper = buildPackages.callPackage ./clippy-helper.nix { frr_version = version; frr_source=src; }; + clippy-helper = buildPackages.callPackage ./clippy-helper.nix { frrVersion = version; frrSource = src; }; configureFlags = [ "--disable-silent-rules"