about summary refs log tree commit diff
path: root/pkgs/servers/frr
diff options
context:
space:
mode:
authorMarkus Theil <theil.markus@gmail.com>2023-07-21 14:40:07 +0200
committerMarkus Theil <theil.markus@gmail.com>2023-08-10 11:06:42 +0200
commit93c0489bdc4d4477ee51a1ec2a072c466b537296 (patch)
tree9334242f590d161289320ab67b1a22d8663203bf /pkgs/servers/frr
parentce5e4a6ef2e59d89a971bc434ca8ca222b9c7f5e (diff)
frr: fix cross compilation x86-64 -> aarch64
Signed-off-by: Markus Theil <theil.markus@gmail.com>
Diffstat (limited to 'pkgs/servers/frr')
-rw-r--r--pkgs/servers/frr/clippy-helper.nix59
-rw-r--r--pkgs/servers/frr/default.nix22
2 files changed, 79 insertions, 2 deletions
diff --git a/pkgs/servers/frr/clippy-helper.nix b/pkgs/servers/frr/clippy-helper.nix
new file mode 100644
index 0000000000000..9e554d4e17e6f
--- /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 f50e3c0b2a8ce..9542e921c5fbf 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 = ''