diff --git a/pkgs/applications/science/molecular-dynamics/gromacs/default.nix b/pkgs/applications/science/molecular-dynamics/gromacs/default.nix index a62e716248e0..f9e70d712b27 100644 --- a/pkgs/applications/science/molecular-dynamics/gromacs/default.nix +++ b/pkgs/applications/science/molecular-dynamics/gromacs/default.nix @@ -1,25 +1,25 @@ -{ lib -, stdenv -, fetchurl -, cmake -, hwloc -, fftw -, perl -, blas -, lapack -, llvmPackages -, mpi -, cudaPackages -, plumed -, singlePrec ? true -, config -, enableCuda ? config.cudaSupport -, enableMpi ? false -, enablePlumed ? false -, cpuAcceleration ? null +{ + lib, + stdenv, + fetchurl, + cmake, + hwloc, + fftw, + perl, + blas, + lapack, + llvmPackages, + mpi, + cudaPackages, + plumed, + singlePrec ? true, + config, + enableCuda ? config.cudaSupport, + enableMpi ? false, + enablePlumed ? false, + cpuAcceleration ? null, }: - # CUDA is only implemented for single precission assert enableCuda -> singlePrec; @@ -30,12 +30,20 @@ let # 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 - if stdenv.hostPlatform.system == "aarch64-linux" then "ARM_NEON_ASIMD" else - "None"; + 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 if stdenv.hostPlatform.system == "aarch64-linux" then + "ARM_NEON_ASIMD" + else + "None"; source = if enablePlumed then @@ -49,7 +57,8 @@ let hash = "sha256-onrTWmRilbvsEpq+aE2dA9Hi4L12sNYl6QVXRqrvroI="; }; -in stdenv.mkDerivation rec { +in +stdenv.mkDerivation rec { pname = "gromacs"; version = source.version; @@ -64,58 +73,73 @@ in stdenv.mkDerivation rec { plumed patch -p -e gromacs-${source.version} ''; - outputs = [ "out" "dev" "man" ]; + outputs = [ + "out" + "dev" + "man" + ]; nativeBuildInputs = [ cmake ] ++ lib.optional enablePlumed plumed ++ lib.optionals enableCuda [ cudaPackages.cuda_nvcc ]; - buildInputs = [ - fftw - perl - hwloc - blas - lapack - ] ++ lib.optional enableMpi mpi - ++ lib.optionals enableCuda [ - cudaPackages.cuda_cccl - cudaPackages.cuda_cudart - cudaPackages.libcufft - cudaPackages.cuda_profiler_api - ] ++ lib.optional stdenv.hostPlatform.isDarwin llvmPackages.openmp; + buildInputs = + [ + fftw + perl + hwloc + blas + lapack + ] + ++ lib.optional enableMpi mpi + ++ lib.optionals enableCuda [ + cudaPackages.cuda_cccl + cudaPackages.cuda_cudart + cudaPackages.libcufft + cudaPackages.cuda_profiler_api + ] + ++ lib.optional stdenv.hostPlatform.isDarwin llvmPackages.openmp; propagatedBuildInputs = lib.optional enableMpi mpi; propagatedUserEnvPkgs = lib.optional enableMpi mpi; - cmakeFlags = [ - (lib.cmakeBool "GMX_HWLOC" true) - "-DGMX_SIMD:STRING=${SIMD cpuAcceleration}" - "-DGMX_OPENMP:BOOL=TRUE" - "-DBUILD_SHARED_LIBS=ON" - ] ++ ( - if singlePrec then [ - "-DGMX_DOUBLE=OFF" - ] else [ - "-DGMX_DOUBLE=ON" - "-DGMX_DEFAULT_SUFFIX=OFF" + cmakeFlags = + [ + (lib.cmakeBool "GMX_HWLOC" true) + "-DGMX_SIMD:STRING=${SIMD cpuAcceleration}" + "-DGMX_OPENMP:BOOL=TRUE" + "-DBUILD_SHARED_LIBS=ON" ] - ) ++ ( - if enableMpi - then [ - "-DGMX_MPI:BOOL=TRUE" - "-DGMX_THREAD_MPI:BOOL=FALSE" - ] - else [ - "-DGMX_MPI:BOOL=FALSE" - ] - ) ++ lib.optionals enableCuda [ - "-DGMX_GPU=CUDA" - (lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cmakeCudaArchitecturesString) + ++ ( + if singlePrec then + [ + "-DGMX_DOUBLE=OFF" + ] + else + [ + "-DGMX_DOUBLE=ON" + "-DGMX_DEFAULT_SUFFIX=OFF" + ] + ) + ++ ( + if enableMpi then + [ + "-DGMX_MPI:BOOL=TRUE" + "-DGMX_THREAD_MPI:BOOL=FALSE" + ] + else + [ + "-DGMX_MPI:BOOL=FALSE" + ] + ) + ++ lib.optionals enableCuda [ + "-DGMX_GPU=CUDA" + (lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cmakeCudaArchitecturesString) - # Gromacs seems to ignore and override the normal variables, so we add this ad hoc: - (lib.cmakeFeature "GMX_CUDA_TARGET_COMPUTE" cmakeCudaArchitecturesString) - ]; + # Gromacs seems to ignore and override the normal variables, so we add this ad hoc: + (lib.cmakeFeature "GMX_CUDA_TARGET_COMPUTE" cmakeCudaArchitecturesString) + ]; postInstall = '' moveToOutput share/cmake $dev @@ -145,6 +169,9 @@ in stdenv.mkDerivation rec { See: https://www.gromacs.org/about.html for details. ''; platforms = platforms.unix; - maintainers = with maintainers; [ sheepforce markuskowa ]; + maintainers = with maintainers; [ + sheepforce + markuskowa + ]; }; }