From 4994570ab3bc5a94363cc91d008be773147861d1 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sat, 3 Jun 2023 15:40:20 +0300 Subject: [PATCH 1/4] lammps: Add doronbehar as maintainer --- pkgs/applications/science/molecular-dynamics/lammps/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/science/molecular-dynamics/lammps/default.nix b/pkgs/applications/science/molecular-dynamics/lammps/default.nix index 51280840a781..5c4550ca7f9b 100644 --- a/pkgs/applications/science/molecular-dynamics/lammps/default.nix +++ b/pkgs/applications/science/molecular-dynamics/lammps/default.nix @@ -62,6 +62,6 @@ stdenv.mkDerivation rec { homepage = "https://lammps.sandia.gov"; license = licenses.gpl2Plus; platforms = platforms.linux; - maintainers = [ maintainers.costrouc ]; + maintainers = [ maintainers.costrouc maintainers.doronbehar ]; }; } From 66c6053b10b6623457b68b2ec7e0fb2a7c651313 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sat, 3 Jun 2023 15:41:16 +0300 Subject: [PATCH 2/4] lammps: 29Oct2020 -> 23Jun2022_update4 --- .../molecular-dynamics/lammps/default.nix | 90 ++++++++++++------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/pkgs/applications/science/molecular-dynamics/lammps/default.nix b/pkgs/applications/science/molecular-dynamics/lammps/default.nix index 5c4550ca7f9b..1707b309cb78 100644 --- a/pkgs/applications/science/molecular-dynamics/lammps/default.nix +++ b/pkgs/applications/science/molecular-dynamics/lammps/default.nix @@ -1,54 +1,76 @@ -{ 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 ]); - - 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/ - ''; + buildInputs = [ + fftw + libpng + blas + lapack + gzip + ] ++ lib.optionals withMPI [ + mpi + ]; meta = with lib; { description = "Classical Molecular Dynamics simulation code"; From 64bed841a96db4156b00e61b98d828fc0c56f5a3 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Tue, 6 Jun 2023 19:15:33 +0300 Subject: [PATCH 3/4] lammps: mark as broken for 32 bit lapack & blas --- .../science/molecular-dynamics/lammps/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/applications/science/molecular-dynamics/lammps/default.nix b/pkgs/applications/science/molecular-dynamics/lammps/default.nix index 1707b309cb78..8f2b0e5c046e 100644 --- a/pkgs/applications/science/molecular-dynamics/lammps/default.nix +++ b/pkgs/applications/science/molecular-dynamics/lammps/default.nix @@ -84,6 +84,10 @@ stdenv.mkDerivation rec { homepage = "https://lammps.sandia.gov"; license = licenses.gpl2Plus; platforms = platforms.linux; + # 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 ]; }; } From 9c992236665be78f24d8e472dde9fbef4d0c06fb Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Tue, 6 Jun 2023 20:11:28 +0300 Subject: [PATCH 4/4] lammps: Add backwards compatible link to lmp_serial --- .../science/molecular-dynamics/lammps/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/applications/science/molecular-dynamics/lammps/default.nix b/pkgs/applications/science/molecular-dynamics/lammps/default.nix index 8f2b0e5c046e..e8ad77f7d4dc 100644 --- a/pkgs/applications/science/molecular-dynamics/lammps/default.nix +++ b/pkgs/applications/science/molecular-dynamics/lammps/default.nix @@ -72,6 +72,11 @@ stdenv.mkDerivation rec { mpi ]; + # For backwards compatibility + postInstall = '' + ln -s $out/bin/lmp $out/bin/lmp_serial + ''; + meta = with lib; { description = "Classical Molecular Dynamics simulation code"; longDescription = ''