From 15c45abf0976fc52df36e8e4bc866ac8b7029a8f Mon Sep 17 00:00:00 2001 From: Tyson Whitehead Date: Fri, 20 Dec 2019 15:42:59 -0500 Subject: [PATCH] mfix: Initial packaging --- pkgs/all-packages.nix | 3 ++ pkgs/mfix/mfixgui.nix | 88 ++++++++++++++++++++++++++++++++++++++++ pkgs/mfix/mfixsolver.nix | 76 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 pkgs/mfix/mfixgui.nix create mode 100644 pkgs/mfix/mfixsolver.nix diff --git a/pkgs/all-packages.nix b/pkgs/all-packages.nix index a401ff3..178799e 100644 --- a/pkgs/all-packages.nix +++ b/pkgs/all-packages.nix @@ -30,6 +30,9 @@ self: super: pkgs: with pkgs; { #meraculous = callPackage ./meraculous.nix { let stdenv49 = overrideCC stdenv gcc49; in stdenv = stdenv49; boost = boost159.override { stdenv = stdenv49 }; }; + mfixgui = python36Packages.callPackage ./mfix/mfixgui.nix { }; + mfixsolver = callPackage ./mfix/mfixsolver.nix { }; + minia = callPackage ./minia.nix { }; inherit (callPackage ./opengl/default.nix { inherit super; }) libGL mesa_glxgallium; diff --git a/pkgs/mfix/mfixgui.nix b/pkgs/mfix/mfixgui.nix new file mode 100644 index 0000000..46eb0d8 --- /dev/null +++ b/pkgs/mfix/mfixgui.nix @@ -0,0 +1,88 @@ +{ lib, fetchurl, fetchFromGitHub, buildPythonApplication, sphinx, sphinx_rtd_theme +, mfixsolver +, numpy, psutil, pyqtgraph, qtpy, pyqt5, vtk, requests, simpleeval, simplejson }: + +buildPythonApplication rec { + pname = "mfixgui"; + version = "19.3.0"; + + srcs = [ + ( fetchurl { + url = "https://mfix.netl.doe.gov/s3/71e94306/f00d8cf543e7a1f42c41a545baef58c4/source/mfix/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 + # + # Should include all the mfixsolver patches as well as it packages the code + # + + # Nix boost libraries are not compiled in static mode + # VTK 7.x doesn't have AnnotationTextScallingOn/Off + # QtCore.Qt colors are lowercase + postPatch = '' + substituteInPlace model/cppmfix/CMakeLists.txt --replace \ + 'set(Boost_USE_STATIC_LIBS ON)' \ + '''''' + substituteInPlace mfixgui/tools/paths.py --replace \ + 'mfix_home = join(conda_prefix(), "share", "mfix")' \ + 'mfix_home = join("'"$out"'", "share", "mfix")' + substituteInPlace mfixgui/vtk_widgets/base.py --replace \ + 'self.scalar_bar.AnnotationTextScalingOff()' \ + 'self.scalar_bar.SetAnnotationTextScaling(0)' + substituteInPlace mfixgui/vtk_widgets/results_viewer.py --replace \ + 'QtCore.Qt.White' \ + 'QtCore.Qt.white' + ''; + + 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" + ''; + + postBuild = '' + python -c "import mfixgui.namelistparser; mfixgui.namelistparser.build_keywords_rst('doc/user_manual/reference')" + ''; + + postInstall = '' + mkdir -p "$out/share/mfix/templates" + cp -rL queue_templates tests tutorials "$out/share/mfix/templates/" + mkdir -p "$out/share/mfix/src" + cp -r CMakeLists.txt cmake model post_mfix tools "$out/share/mfix/src" + sphinx-build -M html doc/user_manual "$out/share/mfix/doc" -t release + wrapProgram "$out/bin/mfix" --prefix PATH : "${mfixsolver}/bin" + ''; + + nativeBuildInputs = [ + sphinx sphinx_rtd_theme + ]; + + buildInputs = [ + mfixsolver + ]; + + # Test routine expects gui export from namespace, but there is none + doCheck = false; + + propagatedBuildInputs = [ + numpy psutil pyqtgraph qtpy pyqt5 vtk requests simpleeval simplejson + ]; + + meta = with lib; { + homepage = https://mfix.netl.doe.gov; + description = "An open-source multiphase flow solver python GUI"; + platforms = platforms.all; + license = licenses.publicDomain; + }; +} diff --git a/pkgs/mfix/mfixsolver.nix b/pkgs/mfix/mfixsolver.nix new file mode 100644 index 0000000..23340d8 --- /dev/null +++ b/pkgs/mfix/mfixsolver.nix @@ -0,0 +1,76 @@ +{ stdenv, fetchurl, fetchFromGitHub +, cmake, gfortran, python, pkgconfig +, openmpi, netcdf, boost }: + +stdenv.mkDerivation rec { + name = "mfixsolver-${version}"; + version = "19.3.0"; + + srcs = [ + ( fetchurl { + url = "https://mfix.netl.doe.gov/s3/71e94306/f00d8cf543e7a1f42c41a545baef58c4/source/mfix/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; + }; +}