Merge pull request #238771 from doronbehar/pkg/lammps-extras

lammps-mpi: Use a generic extraBuildInputs instead of withMpi
This commit is contained in:
Doron Behar 2023-06-22 06:50:03 +00:00 committed by GitHub
commit 636000a5bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 9 deletions

View file

@ -6,11 +6,12 @@
, fftw
, blas
, lapack
, withMPI ? false
, mpi
, cmake
, pkg-config
# Available list of packages can be found near here:
# https://github.com/lammps/lammps/blob/develop/cmake/CMakeLists.txt#L222
#
# - https://github.com/lammps/lammps/blob/develop/cmake/CMakeLists.txt#L222
# - https://docs.lammps.org/Build_extras.html
, packages ? {
ASPHERE = true;
BODY = true;
@ -35,6 +36,10 @@
SRD = true;
REAXFF = true;
}
# Extra cmakeFlags to add as "-D${attr}=${value}"
, extraCmakeFlags ? {}
# Extra `buildInputs` - meant for packages that require more inputs
, extraBuildInputs ? []
}:
stdenv.mkDerivation rec {
@ -53,14 +58,22 @@ stdenv.mkDerivation rec {
'';
nativeBuildInputs = [
cmake
pkg-config
];
passthru = {
inherit mpi;
# Remove these at some point - perhaps after release 23.11. See discussion at:
# https://github.com/NixOS/nixpkgs/pull/238771#discussion_r1235459961
mpi = throw "`lammps-mpi.passthru.mpi` was removed in favor of `extraBuildInputs`";
inherit packages;
inherit extraCmakeFlags;
inherit extraBuildInputs;
};
cmakeFlags = [
] ++ (builtins.map (p: "-DPKG_${p}=ON") (builtins.attrNames (lib.filterAttrs (n: v: v) packages)));
]
++ (builtins.map (p: "-DPKG_${p}=ON") (builtins.attrNames (lib.filterAttrs (n: v: v) packages)))
++ (lib.mapAttrsToList (n: v: "-D${n}=${v}") extraCmakeFlags)
;
buildInputs = [
fftw
@ -68,9 +81,8 @@ stdenv.mkDerivation rec {
blas
lapack
gzip
] ++ lib.optionals withMPI [
mpi
];
] ++ extraBuildInputs
;
# For backwards compatibility
postInstall = ''

View file

@ -38344,7 +38344,11 @@ with pkgs;
fftw = fftw;
};
lammps-mpi = lowPrio (lammps.override { withMPI = true; });
lammps-mpi = lowPrio (lammps.override {
extraBuildInputs = [
mpi
];
});
gromacs = callPackage ../applications/science/molecular-dynamics/gromacs {
singlePrec = true;