Unverified Commit fb5b018f authored by Tyler Langlois's avatar Tyler Langlois Committed by Franz Pletz
Browse files

frr: add optional grpc support via grpcSupport parameter

parent 0a270bfb
Loading
Loading
Loading
Loading
+202 −161
Original line number Diff line number Diff line
{ lib
, stdenv
, fetchFromGitHub
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchpatch,

  # build time
, autoreconfHook
, flex
, bison
, perl
, pkg-config
, texinfo
, buildPackages
  autoreconfHook,
  flex,
  bison,
  perl,
  pkg-config,
  texinfo,
  buildPackages,
  grpc,
  protobuf,
  which,

  # runtime
, c-ares
, json_c
, libcap
, elfutils
, libunwind
, libyang
, net-snmp
, openssl
, pam
, pcre2
, python3
, readline
, rtrlib
, protobufc
, zeromq
  c-ares,
  json_c,
  libcap,
  elfutils,
  libunwind,
  libyang,
  net-snmp,
  openssl,
  pam,
  pcre2,
  python3,
  readline,
  rtrlib,
  protobufc,
  zeromq,

  # tests
, nettools
, nixosTests

  nettools,
  nixosTests,

  # general options
, snmpSupport ? true
, rpkiSupport ? true
, numMultipath ? 64
, watchfrrSupport ? true
, cumulusSupport ? false
, rtadvSupport ? true
, irdpSupport ? true
, routeReplacementSupport ? true
, mgmtdSupport ? true
  snmpSupport ? true,
  rpkiSupport ? true,
  numMultipath ? 64,
  watchfrrSupport ? true,
  cumulusSupport ? false,
  rtadvSupport ? true,
  irdpSupport ? true,
  routeReplacementSupport ? true,
  mgmtdSupport ? true,
  # Experimental as of 10.1, reconsider if upstream changes defaults
  grpcSupport ? false,

  # 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
  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
  bgpAnnounce ? true,
  bgpBmp ? true,
  bgpVnc ? true,

  # OSPF options
, ospfApi ? true
  ospfApi ? true,
}:

stdenv.mkDerivation (finalAttrs: {
@@ -85,18 +91,35 @@ stdenv.mkDerivation (finalAttrs: {
    hash = "sha256-TWqW6kI5dDl6IW2Ql6eeySDSyxp0fPgcJOOX1JxjAxs=";
  };

  nativeBuildInputs = [
  patches = [
    (fetchpatch {
      name = "CVE-2024-44070.patch";
      url = "https://github.com/FRRouting/frr/commit/fea4ed5043b4a523921f970a39a565d2c1ca381f.patch";
      hash = "sha256-X9FjQeOvo92+mL1z3u5W0LBhhePDAyhFAqh8sAtNNm8=";
    })
  ];

  # Without the std explicitly set, we may run into abseil-cpp
  # compilation errors.
  CXXFLAGS = "-std=gnu++23";

  nativeBuildInputs =
    [
      autoreconfHook
      bison
      flex
      perl
      pkg-config
      protobufc
      python3.pkgs.sphinx
      texinfo
    protobufc
    ]
    ++ lib.optionals grpcSupport [
      which
    ];

  buildInputs = [
  buildInputs =
    [
      c-ares
      json_c
      libunwind
@@ -104,17 +127,23 @@ stdenv.mkDerivation (finalAttrs: {
      openssl
      pam
      pcre2
    protobufc
      python3
      readline
      rtrlib
      zeromq
  ] ++ lib.optionals stdenv.hostPlatform.isLinux [
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      libcap
  ] ++ lib.optionals snmpSupport [
    ]
    ++ lib.optionals snmpSupport [
      net-snmp
  ] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform elfutils) [
    ]
    ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform elfutils) [
      elfutils
    ]
    ++ lib.optionals grpcSupport [
      grpc
      protobuf
    ];

  # otherwise in cross-compilation: "configure: error: no working python version found"
@@ -124,9 +153,13 @@ stdenv.mkDerivation (finalAttrs: {

  # 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 { frrVersion = finalAttrs.version; frrSource = finalAttrs.src; };
  clippy-helper = buildPackages.callPackage ./clippy-helper.nix {
    frrVersion = finalAttrs.version;
    frrSource = finalAttrs.src;
  };

  configureFlags = [
  configureFlags =
    [
      "--disable-silent-rules"
      "--disable-exampledir"
      "--enable-configfile-mask=0640"
@@ -147,6 +180,7 @@ stdenv.mkDerivation (finalAttrs: {
      (lib.strings.enableFeature irdpSupport "irdp")
      (lib.strings.enableFeature routeReplacementSupport "rr-semantics")
      (lib.strings.enableFeature mgmtdSupport "mgmtd")
      (lib.strings.enableFeature grpcSupport "grpc")

      # routing protocols
      (lib.strings.enableFeature bgpdSupport "bgpd")
@@ -176,7 +210,8 @@ stdenv.mkDerivation (finalAttrs: {
      (lib.strings.enableFeature ospfApi "ospfapi")
      # Cumulus options
      (lib.strings.enableFeature cumulusSupport "cumulus")
  ] ++ lib.optionals snmpSupport [
    ]
    ++ lib.optionals snmpSupport [
      # Used during build for paths, `dev` has build shebangs so can be run during build.
      "NETSNMP_CONFIG=${lib.getDev net-snmp}/bin/net-snmp-config"
    ];
@@ -221,8 +256,14 @@ stdenv.mkDerivation (finalAttrs: {
      infrastructure, web 2.0 businesses, hyperscale services, and Fortune 500
      private clouds.
    '';
    license = with licenses; [ gpl2Plus lgpl21Plus ];
    maintainers = with maintainers; [ woffs thillux ];
    license = with licenses; [
      gpl2Plus
      lgpl21Plus
    ];
    maintainers = with maintainers; [
      woffs
      thillux
    ];
    # adapt to platforms stated in http://docs.frrouting.org/en/latest/overview.html#supported-platforms
    platforms = (platforms.linux ++ platforms.freebsd ++ platforms.netbsd ++ platforms.openbsd);
  };