2024-01-02 11:29:13 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, cmake
|
|
|
|
, hwloc
|
|
|
|
, fftw
|
|
|
|
, perl
|
|
|
|
, blas
|
|
|
|
, lapack
|
|
|
|
, mpi
|
|
|
|
, cudaPackages
|
|
|
|
, plumed
|
2020-12-09 12:39:15 +00:00
|
|
|
, singlePrec ? true
|
2023-08-04 22:07:22 +00:00
|
|
|
, config
|
|
|
|
, enableCuda ? config.cudaSupport
|
2024-01-02 11:29:13 +00:00
|
|
|
, enableMpi ? false
|
|
|
|
, enablePlumed ? false
|
2020-12-09 12:39:15 +00:00
|
|
|
, cpuAcceleration ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
let
|
2024-01-02 11:29:13 +00:00
|
|
|
inherit (cudaPackages.cudaFlags) cudaCapabilities dropDot;
|
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
# Select reasonable defaults for all major platforms
|
|
|
|
# The possible values are defined in CMakeLists.txt:
|
|
|
|
# AUTO None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256
|
|
|
|
# AVX2_128 AVX_512 AVX_512_KNL MIC ARM_NEON ARM_NEON_ASIMD
|
|
|
|
SIMD = x: if (cpuAcceleration != null) then x else
|
|
|
|
if stdenv.hostPlatform.system == "i686-linux" then "SSE2" else
|
|
|
|
if stdenv.hostPlatform.system == "x86_64-linux" then "SSE4.1" else
|
|
|
|
if stdenv.hostPlatform.system == "x86_64-darwin" then "SSE4.1" else
|
2021-12-06 16:07:01 +00:00
|
|
|
if stdenv.hostPlatform.system == "aarch64-linux" then "ARM_NEON_ASIMD" else
|
2020-12-09 12:39:15 +00:00
|
|
|
"None";
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
source =
|
|
|
|
if enablePlumed then
|
|
|
|
{
|
|
|
|
version = "2023";
|
|
|
|
hash = "sha256-rJLG2nL7vMpBT9io2Xnlbs8XxMHNq+0tpc+05yd7e6g=";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
version = "2023.3";
|
|
|
|
hash = "sha256-Tsj40MevdrE/j9FtuOLBIOdJ3kOa6VVNn2U/gS140cs=";
|
|
|
|
};
|
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "gromacs";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = source.version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2020-12-09 12:39:15 +00:00
|
|
|
url = "ftp://ftp.gromacs.org/pub/gromacs/gromacs-${version}.tar.gz";
|
2024-01-02 11:29:13 +00:00
|
|
|
inherit (source) hash;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
patches = [ ./pkgconfig.patch ];
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
postPatch = lib.optionalString enablePlumed ''
|
|
|
|
plumed patch -p -e gromacs-2023
|
|
|
|
'';
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
outputs = [ "out" "dev" "man" ];
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
nativeBuildInputs =
|
|
|
|
[ cmake ]
|
|
|
|
++ lib.optional enablePlumed plumed
|
|
|
|
++ lib.optionals enableCuda [ cudaPackages.cuda_nvcc ];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
fftw
|
|
|
|
perl
|
|
|
|
hwloc
|
|
|
|
blas
|
|
|
|
lapack
|
|
|
|
] ++ lib.optional enableMpi mpi
|
2024-01-02 11:29:13 +00:00
|
|
|
++ lib.optionals enableCuda [
|
|
|
|
cudaPackages.cuda_cudart
|
|
|
|
cudaPackages.libcufft
|
|
|
|
cudaPackages.cuda_profiler_api
|
|
|
|
];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = lib.optional enableMpi mpi;
|
|
|
|
propagatedUserEnvPkgs = lib.optional enableMpi mpi;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
cmakeFlags = [
|
2024-01-02 11:29:13 +00:00
|
|
|
(lib.cmakeBool "GMX_HWLOC" true)
|
2020-12-09 12:39:15 +00:00
|
|
|
"-DGMX_SIMD:STRING=${SIMD cpuAcceleration}"
|
|
|
|
"-DGMX_OPENMP:BOOL=TRUE"
|
2021-12-06 16:07:01 +00:00
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
2020-12-09 12:39:15 +00:00
|
|
|
] ++ (
|
2020-04-24 23:36:52 +00:00
|
|
|
if singlePrec then [
|
|
|
|
"-DGMX_DOUBLE=OFF"
|
|
|
|
] else [
|
|
|
|
"-DGMX_DOUBLE=ON"
|
|
|
|
"-DGMX_DEFAULT_SUFFIX=OFF"
|
|
|
|
]
|
|
|
|
) ++ (
|
2021-12-06 16:07:01 +00:00
|
|
|
if enableMpi
|
|
|
|
then [
|
|
|
|
"-DGMX_MPI:BOOL=TRUE"
|
|
|
|
"-DGMX_THREAD_MPI:BOOL=FALSE"
|
|
|
|
]
|
|
|
|
else [
|
|
|
|
"-DGMX_MPI:BOOL=FALSE"
|
|
|
|
]
|
2024-01-02 11:29:13 +00:00
|
|
|
) ++ lib.optionals enableCuda [
|
|
|
|
"-DGMX_GPU=CUDA"
|
|
|
|
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" (builtins.concatStringsSep ";" (map dropDot cudaCapabilities)))
|
|
|
|
|
|
|
|
# Gromacs seems to ignore and override the normal variables, so we add this ad hoc:
|
|
|
|
(lib.cmakeFeature "GMX_CUDA_TARGET_COMPUTE" (builtins.concatStringsSep ";" (map dropDot cudaCapabilities)))
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
postInstall = ''
|
|
|
|
moveToOutput share/cmake $dev
|
2022-09-30 11:47:45 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2023-02-22 10:55:15 +00:00
|
|
|
homepage = "https://www.gromacs.org";
|
2023-08-10 07:59:29 +00:00
|
|
|
license = licenses.lgpl21Plus;
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Molecular dynamics software package";
|
|
|
|
longDescription = ''
|
|
|
|
GROMACS is a versatile package to perform molecular dynamics,
|
|
|
|
i.e. simulate the Newtonian equations of motion for systems
|
|
|
|
with hundreds to millions of particles.
|
|
|
|
|
|
|
|
It is primarily designed for biochemical molecules like
|
|
|
|
proteins, lipids and nucleic acids that have a lot of
|
|
|
|
complicated bonded interactions, but since GROMACS is
|
|
|
|
extremely fast at calculating the nonbonded interactions (that
|
|
|
|
usually dominate simulations) many groups are also using it
|
|
|
|
for research on non-biological systems, e.g. polymers.
|
|
|
|
|
|
|
|
GROMACS supports all the usual algorithms you expect from a
|
|
|
|
modern molecular dynamics implementation, (check the online
|
|
|
|
reference or manual for details), but there are also quite a
|
|
|
|
few features that make it stand out from the competition.
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
See: https://www.gromacs.org/about.html for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
platforms = platforms.unix;
|
2021-12-06 16:07:01 +00:00
|
|
|
maintainers = with maintainers; [ sheepforce markuskowa ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|