22 assert blas.isILP64 == lapack.isILP64;
25 versionGA = "5.8.2"; # Fixed by nwchem
27 gaSrc = fetchFromGitHub {
28 owner = "GlobalArrays";
30 rev = "v${versionGA}";
31 hash = "sha256-2ffQIg9topqKX7ygnWaa/UunL9d0Lj9qr9xucsjLuoY=";
35 url = "https://www.chemie.uni-bonn.de/grimme/software/dft-d3/dftd3.tgz";
36 hash = "sha256-2Xz5dY9hqoH9hUJUSPv0pujOB8EukjZzmDGjrzKID1k=";
39 versionLibxc = "6.1.0";
41 url = "https://gitlab.com/libxc/libxc/-/archive/${versionLibxc}/libxc-${versionLibxc}.tar.gz";
42 hash = "sha256-9ZN0X6R+v7ndxGeqr9wvoSdfDXJQxpLOl2E4mpDdjq8=";
45 plumedSrc = fetchFromGitHub {
48 rev = "88f06db71173e7893713a582e5ada7193e8ae1c9";
49 hash = "sha256-p5XNxHcE/QkJ5WdQH/xPp2EyrqCNjA/w/e1R2fkwYts=";
53 stdenv.mkDerivation rec {
57 src = fetchFromGitHub {
60 rev = "v${version}-release";
61 hash = "sha256-2qc4kLb/WmUJuJGonIyS7pgCfyt8yXdcpDAKU0RMY58=";
80 propagatedBuildInputs = [ mpi ];
81 propagatedUserEnvPkgs = [ mpi ];
84 # These run 'configure' in source tree and
85 # require a writable directory
86 cp -r ${gaSrc}/ source/src/tools/ga-${versionGA}
87 chmod -R u+w source/src/tools/ga-${versionGA}
89 cp -r ${plumedSrc} source/src/libext/plumed/plumed2
90 chmod -R u+w source/src/libext/plumed/plumed2
92 # Provide tarball in expected location
93 ln -s ${dftd3Src} source/src/nwpw/nwpwlib/nwpwxc/dftd3.tgz
94 ln -s ${libxcSrc} source/src/libext/libxc/libxc-${versionLibxc}.tar.gz
98 find -type f -executable -exec sed -i "s:/bin/csh:${tcsh}/bin/tcsh:" \{} \;
99 find -type f -name "GNUmakefile" -exec sed -i "s:/usr/bin/gcc:${gcc}/bin/gcc:" \{} \;
100 find -type f -name "GNUmakefile" -exec sed -i "s:/bin/rm:rm:" \{} \;
101 find -type f -executable -exec sed -i "s:/bin/rm:rm:" \{} \;
102 find -type f -name "makelib.h" -exec sed -i "s:/bin/rm:rm:" \{} \;
104 # Overwrite script, skipping the download
105 echo -e '#!/bin/sh\n cd ga-${versionGA};autoreconf -ivf' > src/tools/get-tools-github
107 # /usr/bin/env bash fails in sandbox/Makefile setting
108 substituteInPlace src/config/makefile.h --replace '/usr/bin/env bash' "${stdenv.shell}"
113 # There is no configure script. Instead the build is controlled via
114 # environment variables passed to the Makefile
119 export NWCHEM_TARGET="LINUX64"
121 export ARMCI_NETWORK="MPI-PR"
125 export NWCHEM_MODULES="all python"
127 export USE_PYTHONCONFIG="y"
128 export USE_PYTHON64="n"
129 export PYTHONLIBTYPE="so"
130 export PYTHONHOME="${python3}"
131 export PYTHONVERSION=${lib.versions.majorMinor python3.version}
133 export BLASOPT="-L${blas}/lib -lblas"
134 export LAPACK_LIB="-L${lapack}/lib -llapack"
135 export BLAS_SIZE=${if blas.isILP64 then "8" else "4"}
137 # extra TCE related options
138 export MRCC_METHODS="y"
144 export NWCHEM_TOP="$(pwd)"
146 runHook postConfigure
149 enableParallelBuilding = true;
152 ln -s ${gaSrc} src/tools/ga-${versionGA}.tar.gz
155 ${lib.optionalString (!blas.isILP64) "make 64_to_32"}
159 cd $NWCHEM_TOP/src/util
169 mkdir -p $out/bin $out/share/nwchem
171 cp $NWCHEM_TOP/bin/LINUX64/nwchem $out/bin/nwchem
172 cp -r $NWCHEM_TOP/src/data $out/share/nwchem/
173 cp -r $NWCHEM_TOP/src/basis/libraries $out/share/nwchem/data
174 cp -r $NWCHEM_TOP/src/nwpw/libraryps $out/share/nwchem/data
176 wrapProgram $out/bin/nwchem \
177 --set-default NWCHEM_BASIS_LIBRARY $out/share/nwchem/data/libraries/
179 cat > $out/share/nwchem/nwchemrc << EOF
180 nwchem_basis_library $out/share/nwchem/data/libraries/
181 nwchem_nwpw_library $out/share/nwchem//data/libraryps/
183 amber_1 $out/share/nwchem/data/amber_s/
184 amber_2 $out/share/nwchem/data/amber_q/
185 amber_3 $out/share/nwchem/data/amber_x/
186 amber_4 $out/share/nwchem/data/amber_u/
187 spce $out/share/nwchem/data/solvents/spce.rst
188 charmm_s $out/share/nwchem/data/charmm_s/
189 charmm_x $out/share/nwchem/data/charmm_x/
197 doInstallCheck = true;
198 nativeInstallCheckInputs = [ mpiCheckPhaseHook ];
199 installCheckPhase = ''
200 runHook preInstallCheck
202 # run a simple water test
203 mpirun -np 2 $out/bin/nwchem $NWCHEM_TOP/QA/tests/h2o/h2o.nw > h2o.out
204 grep "Total SCF energy" h2o.out | grep 76.010538
206 runHook postInstallCheck
209 passthru = { inherit mpi; };
212 description = "Open Source High-Performance Computational Chemistry";
213 mainProgram = "nwchem";
214 platforms = [ "x86_64-linux" "aarch64-linux" ];
215 maintainers = with maintainers; [ sheepforce markuskowa ];
216 homepage = "https://nwchemgit.github.io";
217 license = licenses.ecl20;