Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 104 lines 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 cmake, 6 ninja, 7 gfortran, 8 blas, 9 lapack, 10 eigen, 11 useMpi ? false, 12 mpi, 13 mpiCheckPhaseHook, 14 igraph, 15 useAccel ? false, # use Accelerate framework on darwin 16}: 17 18# MPI version can only be built with LP64 interface. 19# See https://github.com/opencollab/arpack-ng#readme 20assert useMpi -> !blas.isILP64; 21assert useAccel -> stdenv.hostPlatform.isDarwin; 22 23stdenv.mkDerivation (finalAttrs: { 24 pname = "arpack${lib.optionalString useMpi "-mpi"}"; 25 version = "3.9.1"; 26 27 src = fetchFromGitHub { 28 owner = "opencollab"; 29 repo = "arpack-ng"; 30 tag = finalAttrs.version; 31 sha256 = "sha256-HCvapLba8oLqx9I5+KDAU0s/dTmdWOEilS75i4gyfC0="; 32 }; 33 34 nativeBuildInputs = [ 35 cmake 36 gfortran 37 ninja 38 ]; 39 buildInputs = [ 40 eigen 41 ] 42 ++ lib.optionals (!useAccel) ( 43 assert (blas.isILP64 == lapack.isILP64); 44 [ 45 blas 46 lapack 47 ] 48 ) 49 ++ lib.optional useMpi mpi; 50 51 nativeCheckInputs = lib.optional useMpi mpiCheckPhaseHook; 52 checkInputs = 53 # work around for `ld: file not found: @rpath/libquadmath.0.dylib` 54 # which occurs due to an mpi test linking with `-flat_namespace` 55 # can remove once `-flat_namespace` is removed or 56 # https://github.com/NixOS/nixpkgs/pull/370526 is merged 57 lib.optional (useMpi && stdenv.hostPlatform.isDarwin) gfortran.cc; 58 59 # a couple tests fail when run in parallel 60 doCheck = true; 61 enableParallelChecking = false; 62 63 env = lib.optionalAttrs useAccel { 64 # Without these flags some tests will fail / segfault when using Accelerate 65 # framework. They were pulled from the CI Workflow 66 # https://github.com/opencollab/arpack-ng/blob/804fa3149a0f773064198a8e883bd021832157ca/.github/workflows/jobs.yml#L184-L192 67 FFLAGS = "-ff2c -fno-second-underscore"; 68 }; 69 70 cmakeFlags = [ 71 (lib.cmakeBool "BUILD_SHARED_LIBS" stdenv.hostPlatform.hasSharedLibraries) 72 (lib.cmakeBool "EIGEN" true) 73 (lib.cmakeBool "EXAMPLES" finalAttrs.finalPackage.doCheck) 74 (lib.cmakeBool "ICB" true) 75 (lib.cmakeBool "INTERFACE64" (!useAccel && blas.isILP64)) 76 (lib.cmakeBool "MPI" useMpi) 77 (lib.cmakeBool "TESTS" finalAttrs.finalPackage.doCheck) 78 ] 79 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 80 "-DBLA_VENDOR=${if useAccel then "Apple" else "Generic"}" 81 ]; 82 83 passthru = { 84 isILP64 = !useAccel && blas.isILP64; 85 tests = { 86 inherit igraph; 87 }; 88 }; 89 90 meta = { 91 homepage = "https://github.com/opencollab/arpack-ng"; 92 changelog = "https://github.com/opencollab/arpack-ng/blob/${finalAttrs.version}/CHANGES"; 93 description = '' 94 A collection of Fortran77 subroutines to solve large scale eigenvalue 95 problems. 96 ''; 97 license = lib.licenses.bsd3; 98 maintainers = with lib.maintainers; [ 99 ttuegel 100 dotlambda 101 ]; 102 platforms = lib.platforms.unix; 103 }; 104})