lammps: patch_2Aug2018 -> stable_22Aug2018

nix derivation was cleaned significantly to follow nixpkgs better
This commit is contained in:
Chris Ostrouchov 2018-09-14 02:09:39 -04:00
parent 7717a2b844
commit 397e15f89e
No known key found for this signature in database
GPG Key ID: 9ED59B0AB1EAF573
2 changed files with 33 additions and 41 deletions

View File

@ -1,63 +1,56 @@
{ lib { stdenv, fetchFromGitHub
, bash , libpng, gzip, fftw, openblas
, stdenv , mpi ? null
, writeText
, fetchFromGitHub
, libpng
, gzip
, fftw
, openblas
, mpiSupport ? false, mpi ? null
}: }:
let packages = [
assert mpiSupport -> mpi != null; "asphere" "body" "class2" "colloid" "compress" "coreshell"
"dipole" "granular" "kspace" "manybody" "mc" "misc" "molecule"
"opt" "peri" "qeq" "replica" "rigid" "shock" "snap" "srd" "user-reaxc"
];
lammps_includes = "-DLAMMPS_EXCEPTIONS -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64";
withMPI = (mpi != null);
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
# LAMMPS has weird versioning converted to ISO 8601 format # LAMMPS has weird versioning converted to ISO 8601 format
version = "patch_2Aug2018"; version = "stable_22Aug2018";
name = "lammps-${version}"; name = "lammps-${version}";
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";
lammps_includes = "-DLAMMPS_EXCEPTIONS -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "lammps"; owner = "lammps";
repo = "lammps"; repo = "lammps";
rev = "${version}"; rev = "${version}";
sha256 = "1ph9pr7s11wgmspmnhxa55bh1pq2cyl8iimfi62lbpbpl9pr1ilc"; sha256 = "1dlifm9wm1jcw2zwal3fnzzl41ng08c7v48w6hx2mz84zljg1nsj";
}; };
passthru = { passthru = {
inherit mpi; inherit mpi;
inherit packages;
}; };
buildInputs = [ fftw libpng openblas gzip bash ] buildInputs = [ fftw libpng openblas gzip ]
++ (stdenv.lib.optionals mpiSupport [ mpi ]); ++ (stdenv.lib.optionals withMPI [ mpi ]);
configurePhase = ''
cd src
for pack in ${stdenv.lib.concatStringsSep " " packages}; do make "yes-$pack" SHELL=$SHELL; done
'';
# Must do manual build due to LAMMPS requiring a seperate build for # Must do manual build due to LAMMPS requiring a seperate build for
# the libraries and executable # the libraries and executable. Also non-typical make script
builder = writeText "builder.sh" '' buildPhase = ''
source $stdenv/setup 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
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
'';
mkdir lammps installPhase = ''
cp -r $src/lib $src/src lammps mkdir -p $out/bin $out/include $out/lib
chmod -R 755 lammps/src/
cd lammps/src
for pack in ${lammps_packages}; do make "yes-$pack" SHELL=$SHELL; done
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
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
mkdir -p $out/bin
cp -v lmp_* $out/bin/ cp -v lmp_* $out/bin/
mkdir -p $out/include
cp -v *.h $out/include/ cp -v *.h $out/include/
mkdir -p $out/lib
cp -v liblammps* $out/lib/ cp -v liblammps* $out/lib/
''; '';
meta = { meta = with stdenv.lib; {
description = "Classical Molecular Dynamics simulation code"; description = "Classical Molecular Dynamics simulation code";
longDescription = '' longDescription = ''
LAMMPS is a classical molecular dynamics simulation code designed to LAMMPS is a classical molecular dynamics simulation code designed to
@ -67,8 +60,8 @@ stdenv.mkDerivation rec {
under the terms of the GNU Public License (GPL). under the terms of the GNU Public License (GPL).
''; '';
homepage = http://lammps.sandia.gov; homepage = http://lammps.sandia.gov;
license = stdenv.lib.licenses.gpl2; license = licenses.gpl2;
platforms = stdenv.lib.platforms.linux; platforms = platforms.linux;
maintainers = with lib.maintainers; [ costrouc ]; maintainers = [ maintainers.costrouc ];
}; };
} }

View File

@ -21146,8 +21146,7 @@ with pkgs;
fftw = fftw; fftw = fftw;
}; };
lammps-mpi = appendToName "mpi" (lammps.override { lammps-mpi = lowPrio (lammps.override {
mpiSupport = true;
mpi = openmpi; mpi = openmpi;
}); });