23 assert blas.isILP64 == lapack.isILP64;
26 versionGA = "5.8.2"; # Fixed by nwchem
28 gaSrc = fetchFromGitHub {
29 owner = "GlobalArrays";
31 rev = "v${versionGA}";
32 hash = "sha256-2ffQIg9topqKX7ygnWaa/UunL9d0Lj9qr9xucsjLuoY=";
36 url = "https://www.chemie.uni-bonn.de/grimme/software/dft-d3/dftd3.tgz";
37 hash = "sha256-2Xz5dY9hqoH9hUJUSPv0pujOB8EukjZzmDGjrzKID1k=";
40 versionLibxc = "6.1.0";
42 url = "https://gitlab.com/libxc/libxc/-/archive/${versionLibxc}/libxc-${versionLibxc}.tar.gz";
43 hash = "sha256-9ZN0X6R+v7ndxGeqr9wvoSdfDXJQxpLOl2E4mpDdjq8=";
46 plumedSrc = fetchFromGitHub {
49 rev = "88f06db71173e7893713a582e5ada7193e8ae1c9";
50 hash = "sha256-p5XNxHcE/QkJ5WdQH/xPp2EyrqCNjA/w/e1R2fkwYts=";
54 stdenv.mkDerivation rec {
58 src = fetchFromGitHub {
61 rev = "v${version}-release";
62 hash = "sha256-2qc4kLb/WmUJuJGonIyS7pgCfyt8yXdcpDAKU0RMY58=";
81 propagatedBuildInputs = [ mpi ];
82 propagatedUserEnvPkgs = [ mpi ];
85 # These run 'configure' in source tree and
86 # require a writable directory
87 cp -r ${gaSrc}/ source/src/tools/ga-${versionGA}
88 chmod -R u+w source/src/tools/ga-${versionGA}
90 cp -r ${plumedSrc} source/src/libext/plumed/plumed2
91 chmod -R u+w source/src/libext/plumed/plumed2
93 # Provide tarball in expected location
94 ln -s ${dftd3Src} source/src/nwpw/nwpwlib/nwpwxc/dftd3.tgz
95 ln -s ${libxcSrc} source/src/libext/libxc/libxc-${versionLibxc}.tar.gz
99 find -type f -executable -exec sed -i "s:/bin/csh:${tcsh}/bin/tcsh:" \{} \;
100 find -type f -name "GNUmakefile" -exec sed -i "s:/usr/bin/gcc:${gcc}/bin/gcc:" \{} \;
101 find -type f -name "GNUmakefile" -exec sed -i "s:/bin/rm:rm:" \{} \;
102 find -type f -executable -exec sed -i "s:/bin/rm:rm:" \{} \;
103 find -type f -name "makelib.h" -exec sed -i "s:/bin/rm:rm:" \{} \;
105 # Overwrite script, skipping the download
106 echo -e '#!/bin/sh\n cd ga-${versionGA};autoreconf -ivf' > src/tools/get-tools-github
108 # /usr/bin/env bash fails in sandbox/Makefile setting
109 substituteInPlace src/config/makefile.h --replace '/usr/bin/env bash' "${stdenv.shell}"
114 # There is no configure script. Instead the build is controlled via
115 # environment variables passed to the Makefile
120 export NWCHEM_TARGET="LINUX64"
122 export ARMCI_NETWORK="MPI-PR"
126 export NWCHEM_MODULES="all python"
128 export USE_PYTHONCONFIG="y"
129 export USE_PYTHON64="n"
130 export PYTHONLIBTYPE="so"
131 export PYTHONHOME="${python3}"
132 export PYTHONVERSION=${lib.versions.majorMinor python3.version}
134 export BLASOPT="-L${blas}/lib -lblas"
135 export LAPACK_LIB="-L${lapack}/lib -llapack"
136 export BLAS_SIZE=${if blas.isILP64 then "8" else "4"}
138 # extra TCE related options
139 export MRCC_METHODS="y"
145 export NWCHEM_TOP="$(pwd)"
147 runHook postConfigure
150 enableParallelBuilding = true;
153 ln -s ${gaSrc} src/tools/ga-${versionGA}.tar.gz
156 ${lib.optionalString (!blas.isILP64) "make 64_to_32"}
160 cd $NWCHEM_TOP/src/util
170 mkdir -p $out/bin $out/share/nwchem
172 cp $NWCHEM_TOP/bin/LINUX64/nwchem $out/bin/nwchem
173 cp -r $NWCHEM_TOP/src/data $out/share/nwchem/
174 cp -r $NWCHEM_TOP/src/basis/libraries $out/share/nwchem/data
175 cp -r $NWCHEM_TOP/src/nwpw/libraryps $out/share/nwchem/data
177 wrapProgram $out/bin/nwchem \
178 --set-default NWCHEM_BASIS_LIBRARY $out/share/nwchem/data/libraries/
180 cat > $out/share/nwchem/nwchemrc << EOF
181 nwchem_basis_library $out/share/nwchem/data/libraries/
182 nwchem_nwpw_library $out/share/nwchem//data/libraryps/
184 amber_1 $out/share/nwchem/data/amber_s/
185 amber_2 $out/share/nwchem/data/amber_q/
186 amber_3 $out/share/nwchem/data/amber_x/
187 amber_4 $out/share/nwchem/data/amber_u/
188 spce $out/share/nwchem/data/solvents/spce.rst
189 charmm_s $out/share/nwchem/data/charmm_s/
190 charmm_x $out/share/nwchem/data/charmm_x/
198 doInstallCheck = true;
199 nativeInstallCheckInputs = [ mpiCheckPhaseHook ];
200 installCheckPhase = ''
201 runHook preInstallCheck
203 # run a simple water test
204 mpirun -np 2 $out/bin/nwchem $NWCHEM_TOP/QA/tests/h2o/h2o.nw > h2o.out
205 grep "Total SCF energy" h2o.out | grep 76.010538
207 runHook postInstallCheck
210 passthru = { inherit mpi; };
213 description = "Open Source High-Performance Computational Chemistry";
214 mainProgram = "nwchem";
219 maintainers = with maintainers; [
223 homepage = "https://nwchemgit.github.io";
224 license = licenses.ecl20;