nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool
2, python3, perl, gmpxx, mpfr, boost, eigen, gfortran, cmake
3, enableFMA ? stdenv.hostPlatform.fmaSupport
4, enableFortran ? true
5}:
6
7let
8 pname = "libint";
9 version = "2.7.1";
10
11 meta = with lib; {
12 description = "Library for the evaluation of molecular integrals of many-body operators over Gaussian functions";
13 homepage = "https://github.com/evaleev/libint";
14 license = with licenses; [ lgpl3Only gpl3Only ];
15 maintainers = with maintainers; [ markuskowa sheepforce ];
16 platforms = [ "x86_64-linux" ];
17 };
18
19 codeGen = stdenv.mkDerivation {
20 inherit pname version;
21
22 src = fetchFromGitHub {
23 owner = "evaleev";
24 repo = pname;
25 rev = "v${version}";
26 sha256 = "5nSeyT1DhFsA76Dt3dqYfhfBYD+iTl34O3lVeH6+OVw=";
27 };
28
29 # Replace hardcoded "/bin/rm" with normal "rm"
30 postPatch = ''
31 for f in \
32 bin/ltmain.sh \
33 configure.ac \
34 src/bin/libint/Makefile \
35 src/lib/libint/Makefile.library \
36 tests/eri/Makefile \
37 tests/hartree-fock/Makefile \
38 tests/unit/Makefile; do
39 substituteInPlace $f --replace "/bin/rm" "rm"
40 done
41 '';
42
43 nativeBuildInputs = [
44 autoconf
45 automake
46 libtool
47 mpfr
48 python3
49 perl
50 gmpxx
51 ] ++ lib.optional enableFortran gfortran;
52
53 buildInputs = [ boost eigen ];
54
55 preConfigure = "./autogen.sh";
56
57 configureFlags = [
58 "--enable-eri=2"
59 "--enable-eri3=2"
60 "--enable-eri2=2"
61 "--with-eri-max-am=7,5,4"
62 "--with-eri-opt-am=3"
63 "--with-eri3-max-am=7"
64 "--with-eri2-max-am=7"
65 "--with-g12-max-am=5"
66 "--with-g12-opt-am=3"
67 "--with-g12dkh-max-am=5"
68 "--with-g12dkh-opt-am=3"
69 "--enable-contracted-ints"
70 "--enable-shared"
71 ] ++ lib.optional enableFMA "--enable-fma";
72
73 makeFlags = [ "export" ];
74
75 installPhase = ''
76 mkdir -p $out
77 cp ${pname}-${version}.tgz $out/.
78 '';
79
80 enableParallelBuilding = true;
81
82 inherit meta;
83 };
84
85 codeComp = stdenv.mkDerivation {
86 inherit pname version;
87
88 src = "${codeGen}/${pname}-${version}.tgz";
89
90 nativeBuildInputs = [
91 python3
92 cmake
93 ] ++ lib.optional enableFortran gfortran;
94
95 buildInputs = [ boost eigen ];
96
97 # Default is just "double", but SSE2 is available on all x86_64 CPUs.
98 # AVX support is advertised, but does not work in 2.6 (possibly in 2.7).
99 # Fortran interface is incompatible with changing the LIBINT2_REALTYPE.
100 cmakeFlags = [
101 (if enableFortran
102 then "-DENABLE_FORTRAN=ON"
103 else "-DLIBINT2_REALTYPE=libint2::simd::VectorSSEDouble"
104 )
105 ];
106
107 # Can only build in the source-tree. A lot of preprocessing magic fails otherwise.
108 dontUseCmakeBuildDir = true;
109
110 inherit meta;
111 };
112
113in codeComp