Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / science / molecular-dynamics / gromacs / default.nix
blob2ca47d812bbfed71f903f1127b91ddc5cacc76b5
1 { lib, stdenv, fetchurl, cmake, hwloc, fftw, perl, blas, lapack, mpi, cudatoolkit
2 , singlePrec ? true
3 , config
4 , enableMpi ? false
5 , enableCuda ? config.cudaSupport
6 , cpuAcceleration ? null
7 }:
9 let
10   # Select reasonable defaults for all major platforms
11   # The possible values are defined in CMakeLists.txt:
12   # AUTO None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256
13   # AVX2_128 AVX_512 AVX_512_KNL MIC ARM_NEON ARM_NEON_ASIMD
14   SIMD = x: if (cpuAcceleration != null) then x else
15     if stdenv.hostPlatform.system == "i686-linux" then "SSE2" else
16     if stdenv.hostPlatform.system == "x86_64-linux" then "SSE4.1" else
17     if stdenv.hostPlatform.system == "x86_64-darwin" then "SSE4.1" else
18     if stdenv.hostPlatform.system == "aarch64-linux" then "ARM_NEON_ASIMD" else
19     "None";
21 in stdenv.mkDerivation rec {
22   pname = "gromacs";
23   version = "2023.3";
25   src = fetchurl {
26     url = "ftp://ftp.gromacs.org/pub/gromacs/gromacs-${version}.tar.gz";
27     sha256 = "sha256-Tsj40MevdrE/j9FtuOLBIOdJ3kOa6VVNn2U/gS140cs=";
28   };
30   patches = [ ./pkgconfig.patch ];
32   outputs = [ "out" "dev" "man" ];
34   nativeBuildInputs = [ cmake ];
36   buildInputs = [
37     fftw
38     perl
39     hwloc
40     blas
41     lapack
42   ] ++ lib.optional enableMpi mpi
43     ++ lib.optional enableCuda cudatoolkit
44   ;
46   propagatedBuildInputs = lib.optional enableMpi mpi;
47   propagatedUserEnvPkgs = lib.optional enableMpi mpi;
49   cmakeFlags = [
50     "-DGMX_SIMD:STRING=${SIMD cpuAcceleration}"
51     "-DGMX_OPENMP:BOOL=TRUE"
52     "-DBUILD_SHARED_LIBS=ON"
53   ] ++ (
54     if singlePrec then [
55       "-DGMX_DOUBLE=OFF"
56     ] else [
57       "-DGMX_DOUBLE=ON"
58       "-DGMX_DEFAULT_SUFFIX=OFF"
59     ]
60   ) ++ (
61     if enableMpi
62       then [
63         "-DGMX_MPI:BOOL=TRUE"
64         "-DGMX_THREAD_MPI:BOOL=FALSE"
65       ]
66      else [
67        "-DGMX_MPI:BOOL=FALSE"
68      ]
69   ) ++ lib.optional enableCuda "-DGMX_GPU=CUDA";
71   postInstall = ''
72     moveToOutput share/cmake $dev
73   '';
75   meta = with lib; {
76     homepage = "https://www.gromacs.org";
77     license = licenses.lgpl21Plus;
78     description = "Molecular dynamics software package";
79     longDescription = ''
80       GROMACS is a versatile package to perform molecular dynamics,
81       i.e. simulate the Newtonian equations of motion for systems
82       with hundreds to millions of particles.
84       It is primarily designed for biochemical molecules like
85       proteins, lipids and nucleic acids that have a lot of
86       complicated bonded interactions, but since GROMACS is
87       extremely fast at calculating the nonbonded interactions (that
88       usually dominate simulations) many groups are also using it
89       for research on non-biological systems, e.g. polymers.
91       GROMACS supports all the usual algorithms you expect from a
92       modern molecular dynamics implementation, (check the online
93       reference or manual for details), but there are also quite a
94       few features that make it stand out from the competition.
96       See: https://www.gromacs.org/about.html for details.
97     '';
98     platforms = platforms.unix;
99     maintainers = with maintainers; [ sheepforce markuskowa ];
100   };