~ehmry/sigil

5600c721079f7cf241873054dfb02322f1c9c359 — Emery Hemingway 3 years ago 8fe0865 eris
LwIP: init at 2.1.2

Build LwIP for testing on Linux. A Genode build of LwIP is still
only available from the Genode Labs repo.
2 files changed, 68 insertions(+), 0 deletions(-)

M overlay/default.nix
A overlay/lwip/default.nix
M overlay/default.nix => overlay/default.nix +2 -0
@@ 147,6 147,8 @@ in nullPkgs // {
      stdenv = gcc7Stdenv;
    });

  lwip = final.callPackage ./lwip { };

  ncurses = addPatchesHost [ ./ncurses/genode.patch ] ncurses;

  nim-unwrapped = prev.nim-unwrapped.overrideAttrs

A overlay/lwip/default.nix => overlay/lwip/default.nix +66 -0
@@ 0,0 1,66 @@
# Package for testing LwIP applications on Linux.

{ lib, stdenv, fetchurl, check, cmake, subunit, unzip }:

let contribName = "contrib-2.1.0";
in stdenv.mkDerivation rec {
  outputs = [ "out" "bin" ];
  pname = "lwip";
  version = "2.1.2";
  srcs = map fetchurl [
    {
      url =
        "http://download.savannah.nongnu.org/releases/${pname}/${pname}-${version}.zip";
      sha256 = "sha256-XgrhiHvvWyfjX5Jjaj5S87xn8ZRPE21sedGOXZcvdrA=";
    }
    {
      url =
        "http://download.savannah.nongnu.org/releases/${pname}/${contribName}.zip";
      sha256 = "sha256-MDif3bQALrfU+dQz2eJb42lOozBxANKXmkjIWJ/Hpo8=";
    }
  ];
  nativeBuildInputs = [ check cmake subunit unzip ];
  sourceRoot = "${pname}-${version}";
  postPatch = ''
    substituteInPlace test/unit/lwip_check.h --replace ',0, 0, 0, 1' ', 0, 0, 1'
  '';
  NIX_CFLAGS_COMPILE = [
    "-Wno-error=format-extra-args"
    "-Wno-error=incompatible-pointer-types"
    "-Wno-error=int-conversion"
  ];
  preConfigure = lib.strings.optionalString stdenv.hostPlatform.isUnix ''
    mv $NIX_BUILD_TOP/$sourceRoot $NIX_BUILD_TOP/lwip
    mv $NIX_BUILD_TOP/${contribName} $NIX_BUILD_TOP/contrib
    cmakeFlagsArray+=("-DLWIP_DIR=$NIX_BUILD_TOP/lwip")
    cmakeFlagsArray+=("-DLWIP_CONTRIB_DIR=$NIX_BUILD_TOP/contrib")
    cd $NIX_BUILD_TOP/contrib/ports/unix/check
    cat >> CMakeLists.txt << EOF
    install(TARGETS lwip_unittests lwipallapps lwipcore)
    install(DIRECTORY
            "\''${LWIP_DIR}/src/include"
            "\''${LWIP_CONTRIB_DIR}/ports/unix/port/include"
        DESTINATION "."
        FILES_MATCHING
        PATTERN "*.h"
    )
    install(FILES "\''${LWIP_CONTRIB_DIR}/ports/unix/lib/lwipopts.h"
        DESTINATION "include/lwip"
    )
    EOF
  '';
  checkPhase = ''
    runHook preCheck
    ./lwip_unittests
    runHook postCheck
  '';
  meta = with lib; {
    broken = !stdenv.hostPlatform.isUnix;
    description =
      "Small independent implementation of the TCP/IP protocol suite";
    homepage = "http://www.nongnu.org/lwip/";
    downloadPage = "http://download.savannah.nongnu.org/releases/lwip/";
    license = licenses.bsd3;
    maintainers = [ maintainers.ehmry ];
  };
}