@@ -1,63 +1,56 @@
1−{ lib
2−, bash
3−, stdenv
4−, writeText
5−, fetchFromGitHub
6−, libpng
7−, gzip
8−, fftw
9−, openblas
10−, mpiSupport ? false, mpi ? null
1+{ stdenv, fetchFromGitHub
2+, libpng, gzip, fftw, openblas
3+, mpi ? null
114}:
12−
13−assert mpiSupport -> mpi != null;
14−
5+let packages = [
6+ "asphere" "body" "class2" "colloid" "compress" "coreshell"
7+ "dipole" "granular" "kspace" "manybody" "mc" "misc" "molecule"
8+ "opt" "peri" "qeq" "replica" "rigid" "shock" "snap" "srd" "user-reaxc"
9+ ];
10+ lammps_includes = "-DLAMMPS_EXCEPTIONS -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64";
11+ withMPI = (mpi != null);
12+in
1513stdenv.mkDerivation rec {
1614 # LAMMPS has weird versioning converted to ISO 8601 format
17− version = "patch_2Aug2018";
15+ version = "stable_22Aug2018";
1816 name = "lammps-${version}";
1917
20− lammps_packages = "asphere body class2 colloid compress coreshell dipole granular kspace manybody mc misc molecule opt peri qeq replica rigid shock snap srd user-reaxc";
21− lammps_includes = "-DLAMMPS_EXCEPTIONS -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64";
22−
2318 src = fetchFromGitHub {
2419 owner = "lammps";
2520 repo = "lammps";
2621 rev = "${version}";
27− sha256 = "1ph9pr7s11wgmspmnhxa55bh1pq2cyl8iimfi62lbpbpl9pr1ilc";
22+ sha256 = "1dlifm9wm1jcw2zwal3fnzzl41ng08c7v48w6hx2mz84zljg1nsj";
2823 };
2924
3025 passthru = {
3126 inherit mpi;
27+ inherit packages;
3228 };
3329
34− buildInputs = [ fftw libpng openblas gzip bash ]
35− ++ (stdenv.lib.optionals mpiSupport [ mpi ]);
30+ buildInputs = [ fftw libpng openblas gzip ]
31+ ++ (stdenv.lib.optionals withMPI [ mpi ]);
32+
33+ configurePhase = ''
34+ cd src
35+ for pack in ${stdenv.lib.concatStringsSep " " packages}; do make "yes-$pack" SHELL=$SHELL; done
36+ '';
3637
3738 # Must do manual build due to LAMMPS requiring a seperate build for
38− # the libraries and executable
39− builder = writeText "builder.sh" ''
40− source $stdenv/setup
39+ # the libraries and executable. Also non-typical make script
40+ buildPhase = ''
41+ make mode=exe ${if withMPI then "mpi" else "serial"} SHELL=$SHELL LMP_INC="${lammps_includes}" FFT_PATH=-DFFT_FFTW3 FFT_LIB=-lfftw3 JPG_LIB=-lpng
42+ make mode=shlib ${if withMPI then "mpi" else "serial"} SHELL=$SHELL LMP_INC="${lammps_includes}" FFT_PATH=-DFFT_FFTW3 FFT_LIB=-lfftw3 JPG_LIB=-lpng
43+ '';
4144
42− mkdir lammps
43− cp -r $src/lib $src/src lammps
44− chmod -R 755 lammps/src/
45− cd lammps/src
46− for pack in ${lammps_packages}; do make "yes-$pack" SHELL=$SHELL; done
47− make mode=exe ${if mpiSupport then "mpi" else "serial"} SHELL=$SHELL LMP_INC="${lammps_includes}" FFT_PATH=-DFFT_FFTW3 FFT_LIB=-lfftw3 JPG_LIB=-lpng
48− make mode=shlib ${if mpiSupport then "mpi" else "serial"} SHELL=$SHELL LMP_INC="${lammps_includes}" FFT_PATH=-DFFT_FFTW3 FFT_LIB=-lfftw3 JPG_LIB=-lpng
45+ installPhase = ''
46+ mkdir -p $out/bin $out/include $out/lib
4947
50− mkdir -p $out/bin
5148 cp -v lmp_* $out/bin/
52−
53− mkdir -p $out/include
5449 cp -v *.h $out/include/
55−
56− mkdir -p $out/lib
5750 cp -v liblammps* $out/lib/
5851 '';
5952
60− meta = {
53+ meta = with stdenv.lib; {
6154 description = "Classical Molecular Dynamics simulation code";
6255 longDescription = ''
6356 LAMMPS is a classical molecular dynamics simulation code designed to
@@ -67,8 +60,8 @@ stdenv.mkDerivation rec {
6760 under the terms of the GNU Public License (GPL).
6861 '';
6962 homepage = http://lammps.sandia.gov;
70− license = stdenv.lib.licenses.gpl2;
71− platforms = stdenv.lib.platforms.linux;
72− maintainers = with lib.maintainers; [ costrouc ];
63+ license = licenses.gpl2;
64+ platforms = platforms.linux;
65+ maintainers = [ maintainers.costrouc ];
7366 };
7467}