cp2k: 2025.1 -> 2025.2, switch to CMake build (#429106)

This commit is contained in:
Markus Kowalewski
2025-08-29 17:09:45 +02:00
committed by GitHub
28 changed files with 864 additions and 302 deletions
@@ -0,0 +1,213 @@
{
lib,
stdenv,
fetchFromGitHub,
mpiCheckPhaseHook,
cmake,
python3,
gfortran,
blas,
lapack,
dbcsr,
fftw,
libint,
libvori,
libxc,
dftd4,
simple-dftd3,
tblite,
mpi,
gsl,
scalapack,
makeWrapper,
libxsmm,
spglib,
which,
pkg-config,
plumed,
zlib,
hdf5-fortran,
sirius,
libvdwxc,
spla,
spfft,
trexio,
toml-f,
greenx,
gmp,
enableElpa ? false,
elpa,
cudaPackages,
rocmPackages,
config,
gpuBackend ? (
if config.cudaSupport then
"cuda"
else if config.rocmSupport then
"rocm"
else
"none"
),
# Change to a value suitable for your target GPU.
# see https://github.com/cp2k/cp2k/blob/master/CMakeLists.txt#L433
hipTarget ? "gfx908",
cudaTarget ? "80",
}:
assert builtins.elem gpuBackend [
"none"
"cuda"
"rocm"
];
stdenv.mkDerivation rec {
pname = "cp2k";
version = "2025.2";
src = fetchFromGitHub {
owner = "cp2k";
repo = "cp2k";
rev = "v${version}";
hash = "sha256-vfl5rCoFeGtYuZ7LcsVsESjKxFbN5IYDvBSzOqsd64w=";
fetchSubmodules = true;
};
patches = [
# Remove the build command line from the source.
# This avoids dependencies to .dev inputs
./remove-compiler-options.patch
# Fix pkg-config path generation
./pkgconfig.patch
];
nativeBuildInputs = [
python3
cmake
which
makeWrapper
pkg-config
]
++ lib.optional (gpuBackend == "cuda") cudaPackages.cuda_nvcc;
buildInputs = [
gfortran
fftw
gsl
libint
libvori
libxc
dftd4
simple-dftd3
tblite
libxsmm
mpi
spglib
scalapack
blas
lapack
dbcsr
plumed
zlib
hdf5-fortran
sirius
spla
spfft
libvdwxc
trexio
toml-f
greenx
gmp
]
++ lib.optional enableElpa elpa
++ lib.optionals (gpuBackend == "cuda") [
cudaPackages.cuda_cudart
cudaPackages.libcublas
cudaPackages.cuda_nvrtc
]
++ lib.optionals (gpuBackend == "rocm") [
rocmPackages.clr
rocmPackages.rocm-core
rocmPackages.hipblas
rocmPackages.hipfft
rocmPackages.rocblas
];
propagatedBuildInputs = [ (lib.getBin mpi) ];
propagatedUserEnvPkgs = [ mpi ];
postPatch = ''
patchShebangs tools exts/dbcsr/tools/build_utils exts/dbcsr/.cp2k
substituteInPlace exts/build_dbcsr/Makefile \
--replace '/usr/bin/env python3' '${python3}/bin/python' \
--replace 'SHELL = /bin/sh' 'SHELL = bash'
'';
cmakeFlags = [
(lib.strings.cmakeBool "CP2K_USE_DFTD4" true)
(lib.strings.cmakeBool "CP2K_USE_TBLITE" true)
(lib.strings.cmakeBool "CP2K_USE_FFTW3" true)
(lib.strings.cmakeBool "CP2K_USE_HDF5" true)
(lib.strings.cmakeBool "CP2K_USE_LIBINT2" true)
(lib.strings.cmakeBool "CP2K_USE_LIBXC" true)
(lib.strings.cmakeBool "CP2K_USE_MPI" true)
(lib.strings.cmakeBool "CP2K_USE_VORI" true)
(lib.strings.cmakeBool "CP2K_USE_TREXIO" true)
(lib.strings.cmakeBool "CP2K_USE_SPGLIB" true)
(lib.strings.cmakeBool "CP2K_USE_SPLA" true)
(lib.strings.cmakeBool "CP2K_USE_LIBXSMM" true)
(lib.strings.cmakeBool "CP2K_USE_SIRIUS" true)
(lib.strings.cmakeBool "CP2K_USE_LIBVDWXC" true)
(lib.strings.cmakeBool "CP2K_USE_PLUMED" true)
(lib.strings.cmakeBool "CP2K_USE_GREENX" true)
(lib.strings.cmakeBool "CP2K_USE_ELPA" enableElpa)
(lib.strings.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic))
]
++ lib.optionals (gpuBackend == "rocm") [
(lib.strings.cmakeFeature "CP2K_USE_ACCEL" "HIP")
(lib.strings.cmakeFeature "CMAKE_HIP_ARCHITECTURES" hipTarget)
]
++ lib.optionals (gpuBackend == "cuda") [
(lib.strings.cmakeFeature "CP2K_USE_ACCEL" "CUDA")
(lib.strings.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaTarget)
];
nativeCheckInputs = [
mpiCheckPhaseHook
];
passthru = {
inherit mpi;
};
postInstall = ''
mkdir -p $out/share/cp2k
cp -r ../data/* $out/share/cp2k
for i in $out/bin/*; do
wrapProgram $i \
--set-default CP2K_DATA_DIR $out/share/cp2k \
--set-default OMP_NUM_THREADS 1
done
'';
doInstallCheck = gpuBackend == "none";
installCheckPhase = ''
runHook preInstallCheck
for TEST in $out/bin/{dbt_tas,dbt,libcp2k,parallel_rng_types,gx_ac}_unittest.psmp; do
mpirun -n 2 $TEST
done
runHook postInstallCheck
'';
meta = {
description = "Quantum chemistry and solid state physics program";
homepage = "https://www.cp2k.org";
license = lib.licenses.gpl2Plus;
maintainers = [ lib.maintainers.sheepforce ];
platforms = [ "x86_64-linux" ];
};
}
@@ -0,0 +1,14 @@
diff --git a/cmake/libcp2k.pc.in b/cmake/libcp2k.pc.in
index 618af55e28..8d08a51a0c 100644
--- a/cmake/libcp2k.pc.in
+++ b/cmake/libcp2k.pc.in
@@ -1,7 +1,7 @@
prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="${prefix}"
-libdir="${prefix}/@CMAKE_INSTALL_LIBDIR@"
-includedir="${prefix}/@CMAKE_INSTALL_INCLUDEDIR@"
+libdir=CMAKE_INSTALL_FULL_LIBDIR@"
+includedir="@CMAKE_INSTALL_FULL_INCLUDEDIR@"
Name: @PROJECT_NAME@
Description: @CMAKE_PROJECT_DESCRIPTION@
-270
View File
@@ -1,270 +0,0 @@
{
lib,
stdenv,
fetchFromGitHub,
mpiCheckPhaseHook,
python3,
gfortran,
blas,
lapack,
fftw,
libint,
libvori,
libxc,
dftd4,
mctc-lib,
mstore,
multicharge,
mpi,
gsl,
scalapack,
makeWrapper,
libxsmm,
spglib,
which,
pkg-config,
plumed,
zlib,
hdf5-fortran,
sirius,
libvdwxc,
spla,
spfft,
enableElpa ? false,
elpa,
cudaPackages,
rocmPackages,
config,
gpuBackend ? (
if config.cudaSupport then
"cuda"
else if config.rocmSupport then
"rocm"
else
"none"
),
# Change to a value suitable for your target GPU.
# For AMD values see https://github.com/cp2k/cp2k/blob/master/INSTALL.md#2v-rocmhip-support-for-amd-gpu
# and for Nvidia see https://github.com/cp2k/cp2k/blob/master/INSTALL.md#2i-cuda-optional-improved-performance-on-gpu-systems
gpuVersion ? (if gpuBackend == "cuda" then "A100" else "Mi100"),
gpuArch ? (if gpuBackend == "cuda" then "sm_80" else "gfx908"),
}:
assert builtins.elem gpuBackend [
"none"
"cuda"
"rocm"
];
let
cp2kVersion = "psmp";
arch = "Linux-x86-64-gfortran";
in
stdenv.mkDerivation rec {
pname = "cp2k";
version = "2025.1";
src = fetchFromGitHub {
owner = "cp2k";
repo = "cp2k";
tag = "v${version}";
hash = "sha256-04AFiEuv+EYubZVoYErQDdr9zipKlF7Gqy8DrUaYUMk=";
fetchSubmodules = true;
};
patches = [
# Remove the build command line from the source.
# This avoids dependencies to .dev inputs
./remove-compiler-options.patch
];
nativeBuildInputs = [
python3
which
makeWrapper
pkg-config
]
++ lib.optional (gpuBackend == "cuda") cudaPackages.cuda_nvcc;
buildInputs = [
gfortran
fftw
gsl
libint
libvori
libxc
dftd4
mctc-lib
mstore
multicharge
libxsmm
mpi
spglib
scalapack
blas
lapack
plumed
zlib
hdf5-fortran
sirius
spla
spfft
libvdwxc
]
++ lib.optional enableElpa elpa
++ lib.optionals (gpuBackend == "cuda") [
cudaPackages.cuda_cudart
cudaPackages.libcublas
cudaPackages.cuda_nvrtc
]
++ lib.optionals (gpuBackend == "rocm") [
rocmPackages.clr
rocmPackages.rocm-core
rocmPackages.hipblas
rocmPackages.hipfft
rocmPackages.rocblas
];
propagatedBuildInputs = [ (lib.getBin mpi) ];
propagatedUserEnvPkgs = [ mpi ];
makeFlags = [
"ARCH=${arch}"
"VERSION=${cp2kVersion}"
];
doCheck = gpuBackend == "none";
enableParallelBuilding = true;
postPatch = ''
patchShebangs tools exts/dbcsr/tools/build_utils exts/dbcsr/.cp2k
substituteInPlace exts/build_dbcsr/Makefile \
--replace '/usr/bin/env python3' '${python3}/bin/python' \
--replace 'SHELL = /bin/sh' 'SHELL = bash'
'';
configurePhase = ''
runHook preConfigure
cat > arch/${arch}.${cp2kVersion} << EOF
CC = mpicc
CPP =
FC = mpif90
LD = mpif90
AR = ar -r
${lib.strings.optionalString (gpuBackend == "cuda") ''
OFFLOAD_CC = nvcc
OFFLOAD_FLAGS = -O3 -g -w --std=c++11 -arch ${gpuArch}
OFFLOAD_TARGET = cuda
GPUVER = ${gpuVersion}
CXX = mpicxx
CXXFLAGS = -std=c++11 -fopenmp
''}
${lib.strings.optionalString (gpuBackend == "rocm") ''
GPUVER = ${gpuVersion}
OFFLOAD_CC = hipcc
OFFLOAD_FLAGS = -fopenmp -m64 -pthread -fPIC -D__GRID_HIP -O2 --offload-arch=${gpuArch} --rocm-path=${rocmPackages.rocm-core}
OFFLOAD_TARGET = hip
CXX = mpicxx
CXXFLAGS = -std=c++11 -fopenmp -D__HIP_PLATFORM_AMD__
''}
DFLAGS = -D__FFTW3 -D__LIBXC -D__LIBINT -D__parallel -D__SCALAPACK \
-D__MPI_VERSION=3 -D__F2008 -D__LIBXSMM -D__SPGLIB \
-D__MAX_CONTR=4 -D__LIBVORI ${lib.optionalString enableElpa "-D__ELPA"} \
-D__PLUMED2 -D__HDF5 -D__GSL -D__SIRIUS -D__LIBVDWXC -D__SPFFT -D__SPLA \
-D__DFTD4 \
${
lib.strings.optionalString (
gpuBackend == "cuda"
) "-D__OFFLOAD_CUDA -D__ACC -D__DBCSR_ACC -D__NO_OFFLOAD_PW"
} \
${lib.strings.optionalString (
gpuBackend == "rocm"
) "-D__OFFLOAD_HIP -D__DBCSR_ACC -D__NO_OFFLOAD_PW"}
CFLAGS = -fopenmp
FCFLAGS = \$(DFLAGS) -O2 -ffree-form -ffree-line-length-none \
-ftree-vectorize -funroll-loops -msse2 \
-std=f2008 \
-fopenmp -ftree-vectorize -funroll-loops \
${lib.optionalString enableElpa "$(pkg-config --variable=fcflags elpa)"} \
-I${lib.getDev libint}/include \
-I${lib.getDev sirius}/include/sirius \
-I${lib.getDev libxc}/include \
-I${lib.getDev dftd4}/include/dftd4 \
-I${lib.getDev libxsmm}/include \
-I${lib.getDev hdf5-fortran}/include \
-fallow-argument-mismatch
LIBS = -lfftw3 -lfftw3_threads \
-lscalapack -lblas -llapack \
-lxcf03 -lxc -lxsmmf -lxsmm -lsymspg \
-lint2 -lstdc++ -lvori \
-lgomp -lpthread -lm \
-fopenmp ${lib.optionalString enableElpa "$(pkg-config --libs elpa)"} \
-lz -ldl ${lib.optionalString (mpi.pname == "openmpi") "$(mpicxx --showme:link)"} \
-lplumed -lhdf5_fortran -lhdf5_hl -lhdf5 -lgsl -lsirius -lspla -lspfft -lvdwxc \
-ldftd4 -lmstore -lmulticharge -lmctc-lib \
${
lib.strings.optionalString (gpuBackend == "cuda") ''
-L${cudaPackages.cuda_cudart}/lib/stubs/ \
-lcudart -lnvrtc -lcuda -lcublas
''
} \
${lib.strings.optionalString (
gpuBackend == "rocm"
) "-lamdhip64 -lhipfft -lhipblas -lrocblas"}
LDFLAGS = \$(FCFLAGS) \$(LIBS)
include ${plumed}/lib/plumed/src/lib/Plumed.inc
EOF
runHook postConfigure
'';
nativeCheckInputs = [
mpiCheckPhaseHook
];
checkPhase = ''
runHook preCheck
export CP2K_DATA_DIR=data
mpirun -np 2 exe/${arch}/libcp2k_unittest.${cp2kVersion}
runHook postCheck
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/share/cp2k
cp exe/${arch}/* $out/bin
rm $out/bin/*_unittest.*
for i in cp2k cp2k_shell graph; do
wrapProgram $out/bin/$i.${cp2kVersion} \
--set-default CP2K_DATA_DIR $out/share/cp2k
done
wrapProgram $out/bin/cp2k.popt \
--set-default CP2K_DATA_DIR $out/share/cp2k \
--set OMP_NUM_THREADS 1
cp -r data/* $out/share/cp2k
runHook postInstall
'';
passthru = {
inherit mpi;
};
meta = {
description = "Quantum chemistry and solid state physics program";
homepage = "https://www.cp2k.org";
license = lib.licenses.gpl2Plus;
maintainers = [ lib.maintainers.sheepforce ];
platforms = [ "x86_64-linux" ];
};
}
+13
View File
@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index 3d6efbb..e338a42 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
+25 -3
View File
@@ -2,7 +2,10 @@
stdenv,
lib,
fetchFromGitHub,
fetchpatch,
gfortran,
buildType ? "meson",
cmake,
meson,
ninja,
pkg-config,
@@ -15,6 +18,12 @@
}:
assert !blas.isILP64 && !lapack.isILP64;
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "dftd4";
@@ -30,24 +39,37 @@ stdenv.mkDerivation rec {
patches = [
# Make sure fortran headers are installed directly in /include
./fortran-module-dir.patch
# Fix wrong generation of package config include paths
./cmake.patch
];
nativeBuildInputs = [
gfortran
meson
ninja
pkg-config
python3
];
]
++ lib.optionals (buildType == "meson") [
meson
ninja
]
++ lib.optional (buildType == "cmake") cmake;
buildInputs = [
blas
lapack
];
propagatedBuildInputs = [
mctc-lib
mstore
multicharge
];
cmakeFlags = [
(lib.strings.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic))
];
outputs = [
"out"
"dev"
+48
View File
@@ -0,0 +1,48 @@
{
stdenv,
lib,
fetchFromGitHub,
gfortran,
cmake,
pkg-config,
blas,
lapack,
}:
stdenv.mkDerivation rec {
pname = "greenx";
version = "2.2";
src = fetchFromGitHub {
owner = "nomad-coe";
repo = "greenx";
rev = "v${version}";
hash = "sha256-otIs2Y79KoEL4ut8YQe7Y27LpmpId8h/X8B6GIg8l+E=";
};
nativeBuildInputs = [
gfortran
pkg-config
cmake
];
buildInputs = [
blas
lapack
];
# Uses a hacky python setup run by cmake, which is hard to get running
doCheck = false;
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = with lib; {
description = "Library for Greens function based electronic structure theory calculations";
license = [ licenses.asl20 ];
homepage = "https://github.com/nomad-coe/greenX";
platforms = platforms.linux;
maintainers = [ maintainers.sheepforce ];
};
}
+13
View File
@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index b2d3c73..00eb732 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=/@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
+71
View File
@@ -0,0 +1,71 @@
{
stdenv,
lib,
fetchFromGitHub,
gfortran,
buildType ? "meson",
meson,
ninja,
cmake,
pkg-config,
test-drive,
toml-f,
}:
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "jonquil";
version = "0.3.0";
src = fetchFromGitHub {
owner = "toml-f";
repo = pname;
rev = "v${version}";
hash = "sha256-2JCTHA0nyA7xE0IA+LNrEAulHU2eIbNRvFGQ7YSQMRE=";
};
patches = [
# Fix wrong generation of package config include paths
./cmake.patch
];
nativeBuildInputs = [
gfortran
pkg-config
]
++ lib.optionals (buildType == "meson") [
meson
ninja
]
++ lib.optional (buildType == "cmake") cmake;
buildInputs = [
test-drive
];
propagatedBuildInputs = [
toml-f
];
outputs = [
"out"
"dev"
];
meta = with lib; {
description = "JSON parser on top of TOML implementation";
license = with licenses; [
asl20
mit
];
homepage = "https://github.com/toml-f/jonquil";
platforms = platforms.linux;
maintainers = [ maintainers.sheepforce ];
};
}
+10 -2
View File
@@ -5,17 +5,25 @@
cmake,
gfortran,
perl,
version ? "6.2.2",
}:
let
versionHashes = {
"6.2.2" = "sha256-JYhuyW95I7Q0edLIe7H//+ej5vh6MdAGxXjmNxDMuhQ=";
"7.0.0" = "sha256-mGyGtKDurOrSS0AYrtwhF62pJGPBLbPPNBgFV7fyyug=";
};
in
stdenv.mkDerivation rec {
pname = "libxc";
version = "6.2.2";
inherit version;
src = fetchFromGitLab {
owner = "libxc";
repo = "libxc";
rev = version;
hash = "sha256-JYhuyW95I7Q0edLIe7H//+ej5vh6MdAGxXjmNxDMuhQ=";
hash = versionHashes."${version}";
};
# Timeout increase has already been included upstream in master.
+29
View File
@@ -0,0 +1,29 @@
diff --git a/config/template.cmake b/config/template.cmake
index 2b3abcbb..59fcd728 100644
--- a/config/template.cmake
+++ b/config/template.cmake
@@ -8,9 +8,7 @@ if(NOT TARGET "@PROJECT_NAME@::@PROJECT_NAME@")
include(CMakeFindDependencyMacro)
- if(NOT TARGET "OpenMP::OpenMP_Fortran" AND "@PROJECT_NAME@_WITH_OpenMP")
- find_dependency("OpenMP")
- endif()
+ find_dependency("OpenMP")
if(NOT TARGET "toml-f::toml-f" AND "@PROJECT_NAME@_WITH_JSON")
find_dependency("toml-f")
diff --git a/config/template.pc b/config/template.pc
index 84c3498c..2da50191 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
+37
View File
@@ -0,0 +1,37 @@
diff --git a/config/meson.build b/config/meson.build
index f54857ee..aaafdb03 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -56,9 +56,12 @@ jonquil_dep = dependency(
'jonquil',
required: get_option('json'),
fallback: ['jonquil','jonquil_dep'],
- default_options: [
- 'default_library=static',
- ],
- static: get_option('default_library') != 'dynamic',
)
lib_deps += jonquil_dep
+
+tomlf_dep = dependency(
+ 'toml-f',
+ required: get_option('json'),
+ fallback: ['toml-f','toml-f_dep'],
+)
+lib_deps += tomlf_dep
diff --git a/meson.build b/meson.build
index 16797c47..6e5290d9 100644
--- a/meson.build
+++ b/meson.build
@@ -25,11 +25,6 @@ project(
)
install = not (meson.is_subproject() and get_option('default_library') == 'static')
-# Check for specific unsupported meson versions
-if meson.version().version_compare('==1.8.0')
- error('Meson version 1.8.0 has a known issue — please use any other version ≥ 0.55.0')
-endif
-
# General configuration information
lib_deps = []
subdir('config')
+31 -7
View File
@@ -3,33 +3,57 @@
lib,
fetchFromGitHub,
gfortran,
buildType ? "meson",
meson,
ninja,
cmake,
pkg-config,
python3,
json-fortran,
toml-f,
jonquil,
}:
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "mctc-lib";
version = "0.4.1";
version = "0.4.2";
src = fetchFromGitHub {
owner = "grimme-lab";
repo = "mctc-lib";
rev = "v${version}";
hash = "sha256-AMRHvzL6CUPItCs07LLOB6Al3yfs8WgrPKRhuNbXiGw=";
hash = "sha256-Qd7mpNE23Z+LuiUwhUzfVzVZEQ+sdnkxMm+W7Hlrss4=";
};
patches = [
# Allow dynamically linked jonquil as dependency. That then additionally
# requires linking in toml-f
./meson.patch
# Fix wrong generation of package config include paths
./cmake.patch
];
nativeBuildInputs = [
gfortran
meson
ninja
pkg-config
python3
];
]
++ lib.optionals (buildType == "meson") [
meson
ninja
]
++ lib.optional (buildType == "cmake") cmake;
buildInputs = [ json-fortran ];
buildInputs = [
jonquil
];
outputs = [
"out"
+20 -3
View File
@@ -3,13 +3,22 @@
lib,
fetchFromGitHub,
gfortran,
buildType ? "meson",
meson,
ninja,
cmake,
pkg-config,
python3,
mctc-lib,
}:
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "mstore";
version = "0.3.0";
@@ -21,13 +30,21 @@ stdenv.mkDerivation rec {
hash = "sha256-zfrxdrZ1Um52qTRNGJoqZNQuHhK3xM/mKfk0aBLrcjw=";
};
patches = [
# Fix wrong generation of package config include paths
./pkgconfig.patch
];
nativeBuildInputs = [
gfortran
meson
ninja
pkg-config
python3
];
]
++ lib.optionals (buildType == "meson") [
meson
ninja
]
++ lib.optional (buildType == "cmake") cmake;
buildInputs = [ mctc-lib ];
+13
View File
@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index 800947d..d388699 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
+22 -3
View File
@@ -3,8 +3,10 @@
lib,
fetchFromGitHub,
gfortran,
buildType ? "meson",
meson,
ninja,
cmake,
pkg-config,
python3,
blas,
@@ -14,6 +16,12 @@
}:
assert !blas.isILP64 && !lapack.isILP64;
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "multicharge";
@@ -26,17 +34,28 @@ stdenv.mkDerivation rec {
hash = "sha256-8qwM3dpvFoL2WrMWNf14zYtRap0ijdfZ95XaTlkHhqQ=";
};
patches = [
# Fix wrong generation of package config include paths
./pkgconfig.patch
];
nativeBuildInputs = [
gfortran
meson
ninja
pkg-config
python3
];
]
++ lib.optionals (buildType == "meson") [
meson
ninja
]
++ lib.optional (buildType == "cmake") cmake;
buildInputs = [
blas
lapack
];
propagatedBuildInputs = [
mctc-lib
mstore
];
@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index 3d6efbb..e338a42 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
@@ -0,0 +1,51 @@
{
stdenv,
lib,
fetchFromGitHub,
gfortran,
cmake,
pkg-config,
armadillo,
blas,
lapack,
}:
stdenv.mkDerivation rec {
pname = "OpenOrbitalOptimizer";
version = "0.1.0";
src = fetchFromGitHub {
owner = "susilethola";
repo = "openorbitaloptimizer";
rev = "v${version}";
hash = "sha256-otIs2Y79KoEL4ut8YQe7Y27LpmpId8h/X8B6GIg8l+E=";
};
nativeBuildInputs = [
pkg-config
cmake
gfortran
];
buildInputs = [
armadillo
blas
lapack
];
outputs = [
"out"
"dev"
];
# Uses a hacky python setup run by cmake, which is hard to get running
doCheck = false;
meta = with lib; {
description = "Common orbital optimisation algorithms for quantum chemistry";
license = [ licenses.mpl20 ];
homepage = "https://github.com/susilehtola/OpenOrbitalOptimizer";
platforms = platforms.linux;
maintainers = [ maintainers.sheepforce ];
};
}
+17 -3
View File
@@ -22,6 +22,12 @@
boost,
eigen,
libvdwxc,
dftd4,
simple-dftd3,
mctc-lib,
jonquil,
toml-f,
multicharge,
enablePython ? false,
pythonPackages ? null,
llvmPackages,
@@ -47,13 +53,13 @@ assert enablePython -> pythonPackages != null;
stdenv.mkDerivation rec {
pname = "SIRIUS";
version = "7.6.2";
version = "7.8.0-unstable-2025-07-23";
src = fetchFromGitHub {
owner = "electronic-structure";
repo = "SIRIUS";
rev = "v${version}";
hash = "sha256-A3WiEzo2ianxdF9HMZN9cT0lFosToGEHh0o6uBSAYqU=";
rev = "258c8c6543af0350ac002a52fbe18221ea275590";
hash = "sha256-HHt3iw3muIGz86NmI9p6yuv7jrXoiz/83qTTueU7Lpk=";
};
outputs = [
@@ -84,6 +90,12 @@ stdenv.mkDerivation rec {
boost
eigen
libvdwxc
jonquil
simple-dftd3
dftd4
mctc-lib
toml-f
multicharge
]
++ lib.optionals (gpuBackend == "cuda") [
cudaPackages.cuda_cudart
@@ -131,6 +143,8 @@ stdenv.mkDerivation rec {
"-DSIRIUS_USE_VDWXC=ON"
"-DSIRIUS_CREATE_FORTRAN_BINDINGS=ON"
"-DSIRIUS_USE_OPENMP=ON"
"-DSIRIUS_USE_DFTD3=ON"
"-DSIRIUS_USE_DFTD4=ON"
"-DBUILD_TESTING=ON"
]
++ lib.optionals (gpuBackend == "cuda") [
+13
View File
@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index 3d6efbb..e338a42 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
+18 -3
View File
@@ -3,11 +3,20 @@
lib,
fetchFromGitHub,
gfortran,
buildType ? "meson",
meson,
ninja,
cmake,
mesonEmulatorHook,
}:
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "test-drive";
version = "0.5.0";
@@ -19,14 +28,20 @@ stdenv.mkDerivation rec {
hash = "sha256-xRx8ErIN9xjxZt/nEsdIQkIGFRltuELdlI8lXA+M030=";
};
patches = [
# Fix wrong generation of package config include paths
./cmake.patch
];
nativeBuildInputs = [
gfortran
]
++ lib.optionals (buildType == "meson") [
meson
ninja
]
++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
mesonEmulatorHook
];
++ lib.optional (buildType == "cmake") cmake
++ lib.optional (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) mesonEmulatorHook;
mesonAutoFeatures = "auto";
+13
View File
@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index 3d6efbb..e338a42 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
+23 -2
View File
@@ -3,12 +3,21 @@
lib,
fetchFromGitHub,
gfortran,
buildType ? "meson",
meson,
ninja,
cmake,
pkg-config,
test-drive,
}:
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "toml-f";
version = "0.4.2";
@@ -20,12 +29,20 @@ stdenv.mkDerivation rec {
hash = "sha256-+cac4rUNpd2w3yBdH1XoCKdJ9IgOHZioZg8AhzGY0FE=";
};
patches = [
# Fix wrong generation of package config include paths
./cmake.patch
];
nativeBuildInputs = [
gfortran
pkg-config
]
++ lib.optionals (buildType == "meson") [
meson
ninja
pkg-config
];
]
++ lib.optional (buildType == "cmake") cmake;
buildInputs = [ test-drive ];
@@ -34,6 +51,10 @@ stdenv.mkDerivation rec {
"dev"
];
cmakeFlags = [
"-Dtest-drive_DIR=${test-drive}"
];
# tftest-build fails on aarch64-linux
doCheck = !stdenv.hostPlatform.isAarch64;
@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index 3d6efbb..e338a42 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
@@ -5,14 +5,22 @@
gfortran,
meson,
ninja,
cmake,
pkg-config,
mctc-lib,
mstore,
toml-f,
blas,
buildType ? "meson",
}:
assert !blas.isILP64;
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "simple-dftd3";
@@ -25,12 +33,19 @@ stdenv.mkDerivation rec {
hash = "sha256-c4xctcMcPQ70ippqbwtinygmnZ5en6ZGF5/v0ZWtzys=";
};
patches = [
./cmake.patch
];
nativeBuildInputs = [
gfortran
pkg-config
]
++ lib.optionals (buildType == "meson") [
meson
ninja
pkg-config
];
]
++ lib.optional (buildType == "cmake") cmake;
buildInputs = [
mctc-lib
@@ -44,6 +59,10 @@ stdenv.mkDerivation rec {
"dev"
];
cmakeFlags = [
(lib.strings.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic))
];
doCheck = true;
preCheck = ''
export OMP_NUM_THREADS=2
@@ -3,8 +3,10 @@
lib,
fetchFromGitHub,
gfortran,
buildType ? "meson",
meson,
ninja,
cmake,
pkg-config,
blas,
lapack,
@@ -14,26 +16,50 @@
multicharge,
dftd4,
simple-dftd3,
python3,
}:
assert !blas.isILP64 && !lapack.isILP64;
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "tblite";
version = "0.4.0";
version = "0.5.0";
src = fetchFromGitHub {
owner = "tblite";
repo = pname;
rev = "v${version}";
hash = "sha256-KV2fxB+SF4LilN/87YCvxUt4wsY4YyIV4tqnn+3/0oI=";
hash = "sha256-hePy/slEeM2o1gtrAbq/nkEUILa6oQjkD2ddDstQ2Zc=";
};
patches = [
./0001-fix-multicharge-dep-needed-for-static-compilation.patch
# Fix wrong paths in pkg-config file
./pkgconfig.patch
];
# Python scripts in test subdirectories to run the tests
postPatch = ''
patchShebangs ./
'';
nativeBuildInputs = [
gfortran
pkg-config
]
++ lib.optionals (buildType == "meson") [
meson
ninja
pkg-config
]
++ lib.optionals (buildType == "cmake") [
cmake
];
buildInputs = [
@@ -52,7 +78,16 @@ stdenv.mkDerivation rec {
"dev"
];
doCheck = true;
checkInputs = [
python3
];
checkFlags = [
"-j1" # Tests hang when multiple are run in parallel
];
doCheck = buildType == "meson";
preCheck = ''
export OMP_NUM_THREADS=2
'';
@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index 3d6efbb..e338a42 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
+71
View File
@@ -14472,6 +14472,8 @@ with pkgs;
avogadro2 = libsForQt5.callPackage ../applications/science/chemistry/avogadro2 { };
libxc_7 = pkgs.libxc.override { version = "7.0.0"; };
molbar = with python3Packages; toPythonApplication molbar;
nwchem = callPackage ../applications/science/chemistry/nwchem {
@@ -14491,6 +14493,75 @@ with pkgs;
siesta-mpi = callPackage ../applications/science/chemistry/siesta { useMpi = true; };
cp2k =
# CP2K requires all dependencies from the Grimme ecosystem to be build with
# CMake instead of Meson. Unfortunately most other consumers require meson
let
grimmeCmake = lib.makeScope pkgs.newScope (self: {
mctc-lib = pkgs.mctc-lib.override {
buildType = "cmake";
inherit (self) jonquil toml-f;
};
toml-f = pkgs.toml-f.override {
buildType = "cmake";
inherit (self) test-drive;
};
dftd4 = pkgs.dftd4.override {
buildType = "cmake";
inherit (self) mstore mctc-lib multicharge;
};
jonquil = pkgs.jonquil.override {
buildType = "cmake";
inherit (self) toml-f test-drive;
};
mstore = pkgs.mstore.override {
buildType = "cmake";
inherit (self) mctc-lib;
};
multicharge = pkgs.multicharge.override {
buildType = "cmake";
inherit (self) mctc-lib mstore;
};
test-drive = pkgs.test-drive.override { buildType = "cmake"; };
simple-dftd3 = pkgs.simple-dftd3.override {
buildType = "cmake";
inherit (self) mctc-lib mstore toml-f;
};
tblite = pkgs.tblite.override {
buildType = "cmake";
inherit (self)
mctc-lib
mstore
toml-f
multicharge
dftd4
simple-dftd3
;
};
sirius = pkgs.sirius.override {
inherit (self)
mctc-lib
toml-f
multicharge
dftd4
simple-dftd3
;
};
});
in
grimmeCmake.callPackage ../applications/science/chemistry/cp2k/default.nix {
libxc = pkgs.libxc_7;
};
### SCIENCE/GEOMETRY
### SCIENCE/BENCHMARK