{ lib, stdenv, pkg-config, net-snmp, erlang, openssl, }: stdenv.mkDerivation { pname = "towerops-nif"; version = "0.1.0"; src = lib.sourceByRegex ../. [ "^c_src" "^c_src/.*\\.c$" "^c_src/.*\\.h$" "^c_src/Makefile$" ]; nativeBuildInputs = [ pkg-config ]; buildInputs = [ net-snmp erlang openssl ]; # Build using the existing Makefile buildPhase = '' runHook preBuild # Find the actual erts include directory export ERL_INCLUDE_PATH=$(find ${erlang}/lib/erlang -type d -name "erts-*" | head -1)/include cd c_src make -j$NIX_BUILD_CORES runHook postBuild ''; # Install the shared library installPhase = '' runHook preInstall mkdir -p $out/lib cp ../priv/towerops_nif.so $out/lib/ runHook postInstall ''; meta = { description = "C NIF for SNMP MIB resolution in Towerops"; license = lib.licenses.unfree; platforms = lib.platforms.unix; }; }