3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #235853 from doronbehar/pkg/lammps

lammps: stable_29Oct2020 -> 23Jun2022_update4
This commit is contained in:
Doron Behar 2023-06-08 11:33:38 +03:00 committed by GitHub
commit 5e87e91405
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,53 +1,80 @@
{ lib, stdenv, fetchFromGitHub
, libpng, gzip, fftw, blas, lapack
{ lib
, stdenv
, fetchFromGitHub
, libpng
, gzip
, fftw
, blas
, lapack
, withMPI ? false
, mpi
, cmake
# Available list of packages can be found near here:
# https://github.com/lammps/lammps/blob/develop/cmake/CMakeLists.txt#L222
, packages ? {
ASPHERE = true;
BODY = true;
CLASS2 = true;
COLLOID = true;
COMPRESS = true;
CORESHELL = true;
DIPOLE = true;
GRANULAR = true;
KSPACE = true;
MANYBODY = true;
MC = true;
MISC = true;
MOLECULE = true;
OPT = true;
PERI = true;
QEQ = true;
REPLICA = true;
RIGID = true;
SHOCK = true;
ML-SNAP = true;
SRD = true;
REAXFF = true;
}
}:
let 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";
in
stdenv.mkDerivation rec {
# LAMMPS has weird versioning converted to ISO 8601 format
version = "stable_29Oct2020";
version = "23Jun2022_update4";
pname = "lammps";
src = fetchFromGitHub {
owner = "lammps";
repo = "lammps";
rev = version;
sha256 = "1rmi9r5wj2z49wg43xyhqn9sm37n95cyli3g7vrqk3ww35mmh21q";
rev = "stable_${version}";
hash = "sha256-zGztc+iUFNIa0KKtfpAhwitInvMmXeTHp1XsOLibfzM=";
};
preConfigure = ''
cd cmake
'';
nativeBuildInputs = [
cmake
];
passthru = {
inherit mpi;
inherit packages;
};
cmakeFlags = [
] ++ (builtins.map (p: "-DPKG_${p}=ON") (builtins.attrNames (lib.filterAttrs (n: v: v) packages)));
buildInputs = [ fftw libpng blas lapack gzip ]
++ (lib.optionals withMPI [ mpi ]);
buildInputs = [
fftw
libpng
blas
lapack
gzip
] ++ lib.optionals withMPI [
mpi
];
configurePhase = ''
cd src
for pack in ${lib.concatStringsSep " " packages}; do make "yes-$pack" SHELL=$SHELL; done
'';
# Must do manual build due to LAMMPS requiring a separate build for
# the libraries and executable. Also non-typical make script
buildPhase = ''
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
'';
installPhase = ''
mkdir -p $out/bin $out/include $out/lib
cp -v lmp_* $out/bin/
cp -v *.h $out/include/
cp -v liblammps* $out/lib/
# For backwards compatibility
postInstall = ''
ln -s $out/bin/lmp $out/bin/lmp_serial
'';
meta = with lib; {
@ -62,6 +89,10 @@ stdenv.mkDerivation rec {
homepage = "https://lammps.sandia.gov";
license = licenses.gpl2Plus;
platforms = platforms.linux;
maintainers = [ maintainers.costrouc ];
# compiling lammps with 64 bit support blas and lapack might cause runtime
# segfaults. In anycase both blas and lapack should have the same #bits
# support.
broken = (blas.isILP64 && lapack.isILP64);
maintainers = [ maintainers.costrouc maintainers.doronbehar ];
};
}