|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + fetchFromGitHub, |
| 5 | + fetchDebianPatch, |
| 6 | + cmake, |
| 7 | + gfortran, |
| 8 | + blas, |
| 9 | + lapack, |
| 10 | + mpi, |
| 11 | + mpiCheckPhaseHook, |
| 12 | + metis, |
| 13 | + parmetis, |
| 14 | + |
| 15 | + # Todo: ask for permission of unfree parmetis |
| 16 | + withParmetis ? false, |
| 17 | +}: |
| 18 | + |
| 19 | +assert (!blas.isILP64) && (!lapack.isILP64); |
| 20 | + |
| 21 | +stdenv.mkDerivation (finalAttrs: { |
| 22 | + pname = "superlu_dist"; |
| 23 | + version = "9.1.0"; |
| 24 | + |
| 25 | + __structuredAttrs = true; |
| 26 | + |
| 27 | + src = fetchFromGitHub { |
| 28 | + owner = "xiaoyeli"; |
| 29 | + repo = "superlu_dist"; |
| 30 | + tag = "v${finalAttrs.version}"; |
| 31 | + # Remove non‐free files. |
| 32 | + postFetch = "rm $out/SRC/prec-independent/mc64ad_dist.c"; |
| 33 | + hash = "sha256-NMAEtTmTY189p8BlmsTugwMuxKZh+Bs1GyuwUHkLA1U="; |
| 34 | + }; |
| 35 | + |
| 36 | + patches = [ |
| 37 | + ./mc64ad_dist-stub.patch |
| 38 | + ]; |
| 39 | + |
| 40 | + postPatch = '' |
| 41 | + substituteInPlace SRC/prec-independent/util.c \ |
| 42 | + --replace-fail "LargeDiag_MC64" "NOROWPERM" |
| 43 | + ''; |
| 44 | + |
| 45 | + nativeBuildInputs = [ |
| 46 | + cmake |
| 47 | + gfortran |
| 48 | + ]; |
| 49 | + |
| 50 | + buildInputs = |
| 51 | + [ |
| 52 | + mpi |
| 53 | + lapack |
| 54 | + ] |
| 55 | + ++ lib.optionals withParmetis [ |
| 56 | + metis |
| 57 | + parmetis |
| 58 | + ]; |
| 59 | + |
| 60 | + propagatedBuildInputs = [ blas ]; |
| 61 | + |
| 62 | + cmakeFlags = |
| 63 | + [ |
| 64 | + (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) |
| 65 | + (lib.cmakeBool "enable_fortran" true) |
| 66 | + (lib.cmakeBool "enable_complex16" true) |
| 67 | + (lib.cmakeBool "TPL_ENABLE_INTERNAL_BLASLIB" false) |
| 68 | + (lib.cmakeBool "TPL_ENABLE_LAPACKLIB" true) |
| 69 | + (lib.cmakeBool "TPL_ENABLE_PARMETISLIB" withParmetis) |
| 70 | + ] |
| 71 | + ++ lib.optionals withParmetis [ |
| 72 | + (lib.cmakeFeature "TPL_PARMETIS_LIBRARIES" "-lmetis -lparmetis") |
| 73 | + (lib.cmakeFeature "TPL_PARMETIS_INCLUDE_DIRS" "${lib.getDev parmetis}/include") |
| 74 | + ]; |
| 75 | + |
| 76 | + doCheck = true; |
| 77 | + |
| 78 | + nativeCheckInputs = [ mpiCheckPhaseHook ]; |
| 79 | + |
| 80 | + meta = { |
| 81 | + homepage = "https://portal.nersc.gov/project/sparse/superlu/"; |
| 82 | + license = with lib.licenses; [ |
| 83 | + # Files: * |
| 84 | + # Lawrence Berkeley National Labs BSD variant license |
| 85 | + bsd3Lbnl |
| 86 | + |
| 87 | + # Files: SRC/prec-independent/symbfact.c |
| 88 | + # Xerox code; actually `Boehm-GC` variant. |
| 89 | + mit |
| 90 | + |
| 91 | + # Files: SRC/include/*colamd.h |
| 92 | + # University of Florida code; permissive COLAMD licence. |
| 93 | + free |
| 94 | + |
| 95 | + # Files: SRC/include/wingetopt.* |
| 96 | + # Microsoft code; Obtained from https://github.com/iotivity/iotivity/tree/master/resource/c_common/windows. |
| 97 | + asl20 |
| 98 | + ]; |
| 99 | + description = "Library for the solution of large, sparse, nonsymmetric systems of linear equations"; |
| 100 | + platforms = lib.platforms.linux; |
| 101 | + maintainers = with lib.maintainers; [ qbisi ]; |
| 102 | + }; |
| 103 | +}) |
0 commit comments