dbcsr: cleanup, fix

This commit is contained in:
Gaetan Lepage
2026-09-29 11:57:30 +00:00
parent f67c2fbed7
commit c092327150

View File

@@ -1,41 +1,69 @@
{
stdenv,
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
# nativeBuildInputs
cmake,
mpiCheckPhaseHook,
pkg-config,
fypp,
gfortran,
mpi,
pkg-config,
python3,
# buildInputs
blas,
lapack,
python3,
libxsmm,
mpi,
# nativeCheckInputs
mpiCheckPhaseHook,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "dbcsr";
version = "2.10.0";
__structuredAttrs = true;
strictDeps = true;
src = fetchFromGitHub {
owner = "cp2k";
repo = "dbcsr";
rev = "v${finalAttrs.version}";
tag = "v${finalAttrs.version}";
hash = "sha256-BgZmc81TzgU3ifv4RHh2pfjbkUyxMIIpBrHCtnLF3p0=";
};
patches = [
# Explicitly export the C API symbols, otherwise hidden with GCC 16
# https://github.com/cp2k/dbcsr/pull/1027
(fetchpatch {
name = "expose-c-api-procedures.patch";
url = "https://github.com/cp2k/dbcsr/commit/a5d9bcfcd487e3181b981687334da1b89bc61dce.patch";
hash = "sha256-a4glOtMx1EUzYdoQb66bZaRnCgatVFWTqvcQlvU3oIc=";
})
];
postPatch = ''
patchShebangs .
# Force build of shared library, otherwise just static.
''
# Force build of shared library, otherwise just static.
+ ''
substituteInPlace src/CMakeLists.txt \
--replace 'add_library(dbcsr ''${DBCSR_SRCS})' 'add_library(dbcsr SHARED ''${DBCSR_SRCS})' \
--replace 'add_library(dbcsr_c ''${DBCSR_C_SRCS})' 'add_library(dbcsr_c SHARED ''${DBCSR_C_SRCS})'
# Avoid calling the fypp wrapper script with python again. The nix wrapper took care of that.
--replace-fail \
'add_library(dbcsr ''${DBCSR_SRCS})' \
'add_library(dbcsr SHARED ''${DBCSR_SRCS})' \
--replace-fail \
'add_library(dbcsr_c ''${DBCSR_C_SRCS})' \
'add_library(dbcsr_c SHARED ''${DBCSR_C_SRCS})'
''
# Avoid calling the fypp wrapper script with python again. The nix wrapper took care of that.
+ ''
substituteInPlace cmake/fypp-sources.cmake \
--replace 'COMMAND ''${Python_EXECUTABLE} ''${FYPP_EXECUTABLE}' 'COMMAND ''${FYPP_EXECUTABLE}'
--replace-fail \
'COMMAND ''${Python_EXECUTABLE} ''${FYPP_EXECUTABLE}' \
'COMMAND ''${FYPP_EXECUTABLE}'
'';
outputs = [
@@ -44,11 +72,12 @@ stdenv.mkDerivation (finalAttrs: {
];
nativeBuildInputs = [
gfortran
python3
cmake
pkg-config
fypp
gfortran
mpi
pkg-config
python3
];
buildInputs = [
@@ -60,17 +89,17 @@ stdenv.mkDerivation (finalAttrs: {
propagatedBuildInputs = [ mpi ];
cmakeFlags = [
"-DUSE_OPENMP=ON"
"-DUSE_SMM=libxsmm"
"-DWITH_C_API=ON"
"-DBUILD_TESTING=ON"
"-DTEST_OMP_THREADS=2"
"-DTEST_MPI_RANKS=2"
"-DENABLE_SHARED=ON"
"-DUSE_MPI=ON"
(lib.cmakeBool "USE_OPENMP" true)
(lib.cmakeFeature "USE_SMM" "libxsmm")
(lib.cmakeBool "WITH_C_API" true)
(lib.cmakeBool "BUILD_TESTING" true)
(lib.cmakeFeature "TEST_OMP_THREADS" "2")
(lib.cmakeFeature "TEST_MPI_RANKS" "2")
(lib.cmakeBool "ENABLE_SHARED" true)
(lib.cmakeBool "USE_MPI" true)
];
checkInputs = [
nativeCheckInputs = [
mpiCheckPhaseHook
];
@@ -80,6 +109,7 @@ stdenv.mkDerivation (finalAttrs: {
description = "Distributed Block Compressed Sparse Row matrix library";
license = lib.licenses.gpl2Only;
homepage = "https://github.com/cp2k/dbcsr";
changelog = "https://github.com/cp2k/dbcsr/releases/tag/${finalAttrs.src.tag}";
maintainers = [ lib.maintainers.sheepforce ];
};
})