|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + fetchFromGitHub, |
| 5 | + fetchpatch2, |
| 6 | + makeWrapper, |
| 7 | + cmake, |
| 8 | + python3Packages, |
| 9 | + mpi, |
| 10 | + mpiCheckPhaseHook, |
| 11 | + metis, |
| 12 | + opencascade-occt, |
| 13 | + libGLU, |
| 14 | + zlib, |
| 15 | + tcl, |
| 16 | + tk, |
| 17 | + xorg, |
| 18 | + libjpeg, |
| 19 | + ffmpeg, |
| 20 | + catch2, |
| 21 | + avxSupport ? stdenv.hostPlatform.avxSupport, |
| 22 | + avx2Support ? stdenv.hostPlatform.avx2Support, |
| 23 | + avx512Support ? stdenv.hostPlatform.avx512Support, |
| 24 | +}: |
| 25 | +let |
| 26 | + archFlags = toString ( |
| 27 | + lib.optional avxSupport "-mavx" |
| 28 | + ++ lib.optional avx2Support "-mavx2" |
| 29 | + ++ lib.optional avx512Support "-mavx512" |
| 30 | + ); |
| 31 | + patchSource = "https://salsa.debian.org/science-team/netgen/-/raw/debian/6.2.2404+dfsg1-5/debian/patches"; |
| 32 | +in |
| 33 | +stdenv.mkDerivation (finalAttrs: { |
| 34 | + pname = "netgen"; |
| 35 | + version = "6.2.2501"; |
| 36 | + |
| 37 | + src = fetchFromGitHub { |
| 38 | + owner = "ngsolve"; |
| 39 | + repo = "netgen"; |
| 40 | + tag = "v${finalAttrs.version}"; |
| 41 | + hash = "sha256-IzYulT3bo7XZiEEy8vNCct0zqHCnbQaH+y4fHMorzZw="; |
| 42 | + }; |
| 43 | + |
| 44 | + patches = [ |
| 45 | + # disable some platform specified code used by downstream ngsolve |
| 46 | + # can be enabled with -march=armv8.3-a+simd when compiling ngsolve |
| 47 | + # note compiling netgen itself is not influenced by this feature |
| 48 | + (fetchpatch2 { |
| 49 | + url = "https://github.com/NGSolve/netgen/pull/197/commits/1d93dfba00f224787cfc2cde1af2ab5d7f5b87f7.patch"; |
| 50 | + hash = "sha256-3Nom4uGhGLtSGn/k+qKKSxVxrGtGTHqPtcNn3D/gkZU"; |
| 51 | + }) |
| 52 | + |
| 53 | + (fetchpatch2 { |
| 54 | + url = "${patchSource}/use-local-catch2.patch"; |
| 55 | + hash = "sha256-h4ob8tl6mvGt5B0qXRFNcl9MxPXxRhYw+PrGr5iRGGk="; |
| 56 | + }) |
| 57 | + (fetchpatch2 { |
| 58 | + url = "${patchSource}/ffmpeg_link_libraries.patch"; |
| 59 | + hash = "sha256-S02OPH9hbJjOnBm6JMh6uM5XptcubV24vdyEF0FusoM="; |
| 60 | + }) |
| 61 | + (fetchpatch2 { |
| 62 | + url = "${patchSource}/fix_nggui_tcl.patch"; |
| 63 | + hash = "sha256-ODDT67+RWBzPhhq/equWsu78x9L/Yrs3U8VQ1Uu0zZw="; |
| 64 | + }) |
| 65 | + (fetchpatch2 { |
| 66 | + url = "${patchSource}/include_stdlib.patch"; |
| 67 | + hash = "sha256-W+NgGBuy/UmzVbPTSqR8FRUlyN/9dl9l9e9rxKklmIc="; |
| 68 | + }) |
| 69 | + (fetchpatch2 { |
| 70 | + url = "${patchSource}/fix-version.patch"; |
| 71 | + hash = "sha256-CT98Wq3UufB81z/jYLiH9nXvt+QzoZ7210OeuFXCfmc="; |
| 72 | + }) |
| 73 | + ]; |
| 74 | + |
| 75 | + # when generating python stub file utilizing system python pybind11_stubgen module |
| 76 | + # cmake need to inherit pythonpath |
| 77 | + postPatch = '' |
| 78 | + substituteInPlace python/CMakeLists.txt \ |
| 79 | + --replace-fail ''\'''${CMAKE_INSTALL_PREFIX}/''${NG_INSTALL_DIR_PYTHON}' \ |
| 80 | + ''\'''${CMAKE_INSTALL_PREFIX}/''${NG_INSTALL_DIR_PYTHON}:$ENV{PYTHONPATH}' |
| 81 | + ''; |
| 82 | + |
| 83 | + nativeBuildInputs = [ |
| 84 | + cmake |
| 85 | + makeWrapper |
| 86 | + python3Packages.pybind11-stubgen |
| 87 | + ]; |
| 88 | + |
| 89 | + buildInputs = [ |
| 90 | + metis |
| 91 | + opencascade-occt |
| 92 | + zlib |
| 93 | + tcl |
| 94 | + tk |
| 95 | + libGLU |
| 96 | + xorg.libXmu |
| 97 | + libjpeg |
| 98 | + ffmpeg |
| 99 | + mpi |
| 100 | + ]; |
| 101 | + |
| 102 | + propagatedBuildInputs = with python3Packages; [ |
| 103 | + packaging |
| 104 | + pybind11 |
| 105 | + mpi4py |
| 106 | + numpy |
| 107 | + ]; |
| 108 | + |
| 109 | + cmakeFlags = [ |
| 110 | + (lib.cmakeFeature "NETGEN_VERSION_GIT" "v${finalAttrs.version}-0") |
| 111 | + (lib.cmakeFeature "CMAKE_CXX_FLAGS" archFlags) |
| 112 | + (lib.cmakeBool "USE_MPI" true) |
| 113 | + (lib.cmakeBool "USE_MPI4PY" true) |
| 114 | + (lib.cmakeBool "PREFER_SYSTEM_PYBIND11" true) |
| 115 | + (lib.cmakeBool "BUILD_STUB_FILES" true) |
| 116 | + (lib.cmakeBool "USE_SUPERBUILD" false) # use system packages |
| 117 | + (lib.cmakeBool "USE_NATIVE_ARCH" false) |
| 118 | + (lib.cmakeBool "USE_JPEG" true) |
| 119 | + (lib.cmakeBool "USE_MPEG" true) |
| 120 | + (lib.cmakeBool "BUILD_TESTING" finalAttrs.finalPackage.doInstallCheck) |
| 121 | + (lib.cmakeBool "ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doInstallCheck) |
| 122 | + ]; |
| 123 | + |
| 124 | + # Tcl script used by netgen need to be aware of environment NETGENDIR |
| 125 | + postInstall = '' |
| 126 | + wrapProgram "$out/bin/netgen" --set NETGENDIR "$out/bin" |
| 127 | + ''; |
| 128 | + |
| 129 | + # mesh generation differs on x86_64 and aarch64 platform |
| 130 | + # tests will fail on aarch64 platform |
| 131 | + doInstallCheck = stdenv.hostPlatform.isx86_64; |
| 132 | + |
| 133 | + preInstallCheck = '' |
| 134 | + export PYTHONPATH=$out/${python3Packages.python.sitePackages}:$PYTHONPATH |
| 135 | + ''; |
| 136 | + |
| 137 | + installCheckTarget = "test"; |
| 138 | + |
| 139 | + nativeInstallCheckInputs = [ |
| 140 | + catch2 |
| 141 | + python3Packages.pytest |
| 142 | + python3Packages.pytest-check |
| 143 | + python3Packages.pytest-mpi |
| 144 | + mpiCheckPhaseHook |
| 145 | + ]; |
| 146 | + |
| 147 | + passthru = { |
| 148 | + inherit avxSupport avx2Support avx512Support; |
| 149 | + }; |
| 150 | + |
| 151 | + meta = { |
| 152 | + homepage = "https://ngsolve.org"; |
| 153 | + description = "Atomatic 3d tetrahedral mesh generator"; |
| 154 | + license = with lib.licenses; [ |
| 155 | + lgpl2Plus |
| 156 | + lgpl21Plus |
| 157 | + lgpl21Only |
| 158 | + bsd3 |
| 159 | + boost |
| 160 | + publicDomain |
| 161 | + ]; |
| 162 | + platforms = [ |
| 163 | + "x86_64-linux" |
| 164 | + "aarch64-linux" |
| 165 | + ]; |
| 166 | + mainProgram = "netgen"; |
| 167 | + maintainers = with lib.maintainers; [ qbisi ]; |
| 168 | + }; |
| 169 | +}) |
0 commit comments