From 93c0489bdc4d4477ee51a1ec2a072c466b537296 Mon Sep 17 00:00:00 2001 From: Markus Theil Date: Fri, 21 Jul 2023 14:40:07 +0200 Subject: [PATCH] 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 = ''