{ stdenv, fetchurl, fetchFromGitHub , cmake, gfortran, python, pkgconfig , openmpi, netcdf, boost }: stdenv.mkDerivation rec { name = "mfixsolver-${version}"; version = "19.3.0"; srcs = [ ( fetchurl { url = "https://staff.sharcnet.ca/~tyson/nix/mfix-${version}.tar.gz"; sha256 = "1bnwvgmrmz9y32fsnnqb4x2ab4yh9iyg1d7f3wc2w6q9fsfnzpj4"; } ) ( fetchFromGitHub { name = "crow_repo"; owner = "mwm126"; repo = "crow"; rev = "e87cbf55897be4ca134c4e3fd2c58154d4fb3b7b"; sha256 = "0wc4x0dwhqlzw438spvflvmp56xphkwy83mlcrh9byw0yh96wdv9"; } ) ]; sourceRoot = "mfix-${version}"; # # See the various build_* files under conda # postUnpack = '' python "$NIX_BUILD_TOP/crow_repo/amalgamate/merge_all.py" "$NIX_BUILD_TOP/crow_repo/include" mv crow_all.h "$sourceRoot/model/cppmfix/crow.h" ''; # Put the binaries under a bin subdirectory # Nix boost libraries are not compiled in static mode postPatch = '' substituteInPlace CMakeLists.txt --replace \ 'install(TARGETS mfixsolver DESTINATION ''${CMAKE_INSTALL_PREFIX})' \ 'install(TARGETS mfixsolver DESTINATION bin)' substituteInPlace post_mfix/CMakeLists.txt --replace \ 'install(TARGETS postmfix DESTINATION ''${CMAKE_INSTALL_PREFIX})' \ 'install(TARGETS postmfix DESTINATION bin)' substituteInPlace model/cppmfix/CMakeLists.txt --replace \ 'set(Boost_USE_STATIC_LIBS ON)' \ '''''' ''; cmakeFlags = [ "-DVERSION=${version}" "-DENABLE_POSTMFIX=ON" "-DENABLE_MPI=ON" "-DENABLE_CPPMFIX=ON" # "-DENABLE_NETCDF=ON" -- Requires NETCDF built by cmake (input netcdf) # "-DENABLE_OpenMP" -- Probably no need if using MPI ]; nativeBuildInputs = [ python pkgconfig ]; buildInputs = [ cmake gfortran openmpi boost # netcdf ]; meta = with stdenv.lib; { homepage = https://mfix.netl.doe.gov; description = "An open-source multiphase flow solver"; platforms = platforms.all; license = licenses.publicDomain; }; }