16 , enableCuda ? config.cudaSupport
18 , enablePlumed ? false
19 , cpuAcceleration ? null
23 # CUDA is only implemented for single precission
24 assert enableCuda -> singlePrec;
27 inherit (cudaPackages.flags) cmakeCudaArchitecturesString;
29 # Select reasonable defaults for all major platforms
30 # The possible values are defined in CMakeLists.txt:
31 # AUTO None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256
32 # AVX2_128 AVX_512 AVX_512_KNL MIC ARM_NEON ARM_NEON_ASIMD
33 SIMD = x: if (cpuAcceleration != null) then x else
34 if stdenv.hostPlatform.system == "i686-linux" then "SSE2" else
35 if stdenv.hostPlatform.system == "x86_64-linux" then "SSE4.1" else
36 if stdenv.hostPlatform.system == "x86_64-darwin" then "SSE4.1" else
37 if stdenv.hostPlatform.system == "aarch64-linux" then "ARM_NEON_ASIMD" else
44 hash = "sha256-gCp+M18uiVdw9XsVnk7DaOuw/yzm2sz3BsboAlw2hSs=";
49 hash = "sha256-rGGOzi5Yr6hrU2xaLE/Lk38HYDGPEtGPEDRra969hqg=";
52 in stdenv.mkDerivation rec {
54 version = source.version;
57 url = "ftp://ftp.gromacs.org/pub/gromacs/gromacs-${version}.tar.gz";
58 inherit (source) hash;
61 patches = [ ./pkgconfig.patch ];
63 postPatch = lib.optionalString enablePlumed ''
64 plumed patch -p -e gromacs-${source.version}
67 outputs = [ "out" "dev" "man" ];
71 ++ lib.optional enablePlumed plumed
72 ++ lib.optionals enableCuda [ cudaPackages.cuda_nvcc ];
80 ] ++ lib.optional enableMpi mpi
81 ++ lib.optionals enableCuda [
82 cudaPackages.cuda_cccl
83 cudaPackages.cuda_cudart
85 cudaPackages.cuda_profiler_api
86 ] ++ lib.optional stdenv.hostPlatform.isDarwin llvmPackages.openmp;
88 propagatedBuildInputs = lib.optional enableMpi mpi;
89 propagatedUserEnvPkgs = lib.optional enableMpi mpi;
92 (lib.cmakeBool "GMX_HWLOC" true)
93 "-DGMX_SIMD:STRING=${SIMD cpuAcceleration}"
94 "-DGMX_OPENMP:BOOL=TRUE"
95 "-DBUILD_SHARED_LIBS=ON"
101 "-DGMX_DEFAULT_SUFFIX=OFF"
106 "-DGMX_MPI:BOOL=TRUE"
107 "-DGMX_THREAD_MPI:BOOL=FALSE"
110 "-DGMX_MPI:BOOL=FALSE"
112 ) ++ lib.optionals enableCuda [
114 (lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cmakeCudaArchitecturesString)
116 # Gromacs seems to ignore and override the normal variables, so we add this ad hoc:
117 (lib.cmakeFeature "GMX_CUDA_TARGET_COMPUTE" cmakeCudaArchitecturesString)
121 moveToOutput share/cmake $dev
125 homepage = "https://www.gromacs.org";
126 license = licenses.lgpl21Plus;
127 description = "Molecular dynamics software package";
129 GROMACS is a versatile package to perform molecular dynamics,
130 i.e. simulate the Newtonian equations of motion for systems
131 with hundreds to millions of particles.
133 It is primarily designed for biochemical molecules like
134 proteins, lipids and nucleic acids that have a lot of
135 complicated bonded interactions, but since GROMACS is
136 extremely fast at calculating the nonbonded interactions (that
137 usually dominate simulations) many groups are also using it
138 for research on non-biological systems, e.g. polymers.
140 GROMACS supports all the usual algorithms you expect from a
141 modern molecular dynamics implementation, (check the online
142 reference or manual for details), but there are also quite a
143 few features that make it stand out from the competition.
145 See: https://www.gromacs.org/about.html for details.
147 platforms = platforms.unix;
148 maintainers = with maintainers; [ sheepforce markuskowa ];