Skip to content

Commit

Permalink
lammps and python312Packages.lammps related fixes (#342532)
Browse files Browse the repository at this point in the history
  • Loading branch information
doronbehar committed Sep 30, 2024
2 parents 90f5daf + 4c7de25 commit 546d75c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
{ lib
, stdenv
, fetchFromGitHub
, libpng
, gzip
, fftw
, blas
, lapack
, cmake
, autoAddDriverRunpath
, pkg-config
# Available list of packages can be found near here:
#
# - https://github.com/lammps/lammps/blob/develop/cmake/CMakeLists.txt#L222
# - https://docs.lammps.org/Build_extras.html
, 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;
}
# Extra cmakeFlags to add as "-D${attr}=${value}"
, extraCmakeFlags ? {}
# Extra `buildInputs` - meant for packages that require more inputs
, extraBuildInputs ? []
{
lib,
stdenv,
fetchFromGitHub,
libpng,
gzip,
fftw,
blas,
lapack,
python3,
cmake,
autoAddDriverRunpath,
pkg-config,
# Available list of packages can be found near here:
#
# - https://github.com/lammps/lammps/blob/develop/cmake/CMakeLists.txt#L222
# - https://docs.lammps.org/Build_extras.html
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;
PYTHON = true;
},
# Extra cmakeFlags to add as "-D${attr}=${value}"
extraCmakeFlags ? { },
# Extra `buildInputs` - meant for packages that require more inputs
extraBuildInputs ? [ ],
}:

stdenv.mkDerivation (finalAttrs: {
Expand Down Expand Up @@ -74,21 +77,20 @@ stdenv.mkDerivation (finalAttrs: {
inherit extraCmakeFlags;
inherit extraBuildInputs;
};
cmakeFlags = [
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
]
++ (lib.mapAttrsToList (n: v: lib.cmakeBool "PKG_${n}" v) packages)
++ (lib.mapAttrsToList (n: v: "-D${n}=${v}") extraCmakeFlags)
;
cmakeFlags =
[
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
]
++ (lib.mapAttrsToList (n: v: lib.cmakeBool "PKG_${n}" v) packages)
++ (lib.mapAttrsToList (n: v: "-D${n}=${v}") extraCmakeFlags);

buildInputs = [
fftw
libpng
blas
lapack
gzip
] ++ extraBuildInputs
;
] ++ lib.optionals packages.PYTHON [ python3 ] ++ extraBuildInputs;

postInstall = ''
# For backwards compatibility
Expand All @@ -108,7 +110,7 @@ stdenv.mkDerivation (finalAttrs: {
National Laboratories, a US Department of Energy facility, with
funding from the DOE. It is an open-source code, distributed freely
under the terms of the GNU Public License (GPL).
'';
'';
homepage = "https://www.lammps.org";
license = lib.licenses.gpl2Only;
platforms = lib.platforms.linux;
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/python-modules/lammps/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ buildPythonPackage {
inherit (lammps) pname version src;

env = {
# Needed for tests
inherit LAMMPS_SHARED_LIB;
};
# Don't perform checks if GPU is enabled - because libcuda.so cannot be opened in the sandbox
doCheck = if lammps.passthru.packages ? GPU then !lammps.passthru.packages.GPU else true;
preConfigure = ''
cd python
# Upstream assumes that the shared library is located in the same directory
Expand Down
4 changes: 0 additions & 4 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36556,10 +36556,6 @@ with pkgs;

dl-poly-classic-mpi = callPackage ../applications/science/molecular-dynamics/dl-poly-classic { };

lammps = callPackage ../applications/science/molecular-dynamics/lammps {
fftw = fftw;
};

lammps-mpi = lowPrio (lammps.override {
extraBuildInputs = [
mpi
Expand Down

0 comments on commit 546d75c

Please sign in to comment.