From 78574df36c0759757d5aed55b8219779102c5a7d Mon Sep 17 00:00:00 2001 From: qbisi Date: Wed, 24 Sep 2025 04:35:34 +0800 Subject: [PATCH 1/7] petsc: replace withPtscotch with withPtScotch Keep aligned with MUMPS and Scotch override options. --- pkgs/by-name/pe/petsc/package.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/pe/petsc/package.nix b/pkgs/by-name/pe/petsc/package.nix index ed989be6f710..f0ceca6a100f 100644 --- a/pkgs/by-name/pe/petsc/package.nix +++ b/pkgs/by-name/pe/petsc/package.nix @@ -26,10 +26,10 @@ # External libraries options withHdf5 ? withCommonDeps, withMetis ? withCommonDeps, - withZlib ? (withP4est || withPtscotch), + withZlib ? (withP4est || withPtScotch), withScalapack ? withCommonDeps && mpiSupport, withParmetis ? withFullDeps, # parmetis is unfree - withPtscotch ? withCommonDeps && mpiSupport, + withPtScotch ? withCommonDeps && mpiSupport, withMumps ? withCommonDeps, withP4est ? withFullDeps, withHypre ? withCommonDeps && mpiSupport, @@ -67,7 +67,7 @@ assert withP4est -> (mpiSupport && withZlib); # Package parmetis depend on metis and mpi support assert withParmetis -> (withMetis && mpiSupport); -assert withPtscotch -> (mpiSupport && withZlib); +assert withPtScotch -> (mpiSupport && withZlib); assert withScalapack -> mpiSupport; assert (withMumps && mpiSupport) -> withScalapack; assert withHypre -> mpiSupport; @@ -83,6 +83,7 @@ let fortranSupport pythonSupport precision + withPtScotch ; enableMpi = self.mpiSupport; @@ -139,7 +140,7 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional withP4est petscPackages.p4est ++ lib.optional withMetis petscPackages.metis ++ lib.optional withParmetis petscPackages.parmetis - ++ lib.optional withPtscotch petscPackages.scotch + ++ lib.optional withPtScotch petscPackages.scotch ++ lib.optional withScalapack petscPackages.scalapack ++ lib.optional withMumps petscPackages.mumps ++ lib.optional withHypre petscPackages.hypre @@ -184,7 +185,7 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional pythonSupport "--with-petsc4py=1" ++ lib.optional withMetis "--with-metis=1" ++ lib.optional withParmetis "--with-parmetis=1" - ++ lib.optional withPtscotch "--with-ptscotch=1" + ++ lib.optional withPtScotch "--with-ptscotch=1" ++ lib.optional withScalapack "--with-scalapack=1" ++ lib.optional withMumps "--with-mumps=1" ++ lib.optional (withMumps && !mpiSupport) "--with-mumps-serial=1" From 761acfcd01145dba03fd126e5532d22c809fd6bd Mon Sep 17 00:00:00 2001 From: qbisi Date: Wed, 24 Sep 2025 04:47:19 +0800 Subject: [PATCH 2/7] petsc: remove hardeningDisable options Disabling fortify is no longer required for debug builds. --- pkgs/by-name/pe/petsc/package.nix | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkgs/by-name/pe/petsc/package.nix b/pkgs/by-name/pe/petsc/package.nix index f0ceca6a100f..eb43dea2d22b 100644 --- a/pkgs/by-name/pe/petsc/package.nix +++ b/pkgs/by-name/pe/petsc/package.nix @@ -198,11 +198,6 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional withFftw "--with-fftw=1" ++ lib.optional withSuitesparse "--with-suitesparse=1"; - hardeningDisable = lib.optionals debug [ - "fortify" - "fortify3" - ]; - installTargets = [ (if withExamples then "install" else "install-lib") ]; enableParallelBuilding = true; From 04ed517174c6134aa5d5128d523cea428fadd67a Mon Sep 17 00:00:00 2001 From: qbisi Date: Sat, 27 Sep 2025 17:57:17 +0800 Subject: [PATCH 3/7] mumps: use pname --- pkgs/by-name/mu/mumps/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/mu/mumps/package.nix b/pkgs/by-name/mu/mumps/package.nix index 748ba7ca4913..a845e9175e63 100644 --- a/pkgs/by-name/mu/mumps/package.nix +++ b/pkgs/by-name/mu/mumps/package.nix @@ -47,7 +47,7 @@ let ); in stdenv.mkDerivation (finalAttrs: { - name = "mumps"; + pname = "mumps"; version = "5.8.1"; # makeFlags contain space and one should use makeFlagsArray+ # Setting this magic var is an optional solution From 39ce7b7cf219ace81d06e59277d421f9069de554 Mon Sep 17 00:00:00 2001 From: qbisi Date: Fri, 26 Sep 2025 20:27:44 +0800 Subject: [PATCH 4/7] scotch: add qbisi to maintainers --- pkgs/by-name/sc/scotch/package.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/sc/scotch/package.nix b/pkgs/by-name/sc/scotch/package.nix index b15a1a66f0a5..2fd91f8ff215 100644 --- a/pkgs/by-name/sc/scotch/package.nix +++ b/pkgs/by-name/sc/scotch/package.nix @@ -54,6 +54,9 @@ stdenv.mkDerivation (finalAttrs: { ''; homepage = "http://www.labri.fr/perso/pelegrin/scotch"; license = lib.licenses.cecill-c; - maintainers = [ lib.maintainers.bzizou ]; + maintainers = with lib.maintainers; [ + bzizou + qbisi + ]; }; }) From 190975084db68798309507a0c2a9e611a51cbec3 Mon Sep 17 00:00:00 2001 From: qbisi Date: Fri, 26 Sep 2025 18:45:32 +0800 Subject: [PATCH 5/7] scotch: sort build inputs --- pkgs/by-name/sc/scotch/package.nix | 39 +++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/sc/scotch/package.nix b/pkgs/by-name/sc/scotch/package.nix index 2fd91f8ff215..2173f79902a4 100644 --- a/pkgs/by-name/sc/scotch/package.nix +++ b/pkgs/by-name/sc/scotch/package.nix @@ -1,15 +1,16 @@ { - bison, - bzip2, - cmake, - fetchFromGitLab, - flex, - gfortran, lib, - mpi, stdenv, - zlib, + fetchFromGitLab, + cmake, + gfortran, + bison, + flex, + bzip2, xz, + zlib, + mpi, + testers, }: stdenv.mkDerivation (finalAttrs: { @@ -30,22 +31,36 @@ stdenv.mkDerivation (finalAttrs: { "out" ]; - cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ]; + cmakeFlags = [ + (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) + ]; nativeBuildInputs = [ cmake gfortran + bison + flex ]; buildInputs = [ - bison bzip2 - mpi - flex xz zlib ]; + propagatedBuildInputs = [ + mpi + ]; + + passthru = { + tests = { + cmake-config = testers.hasCmakeConfigModules { + moduleNames = [ "SCOTCH" ]; + package = finalAttrs.finalPackage; + }; + }; + }; + meta = { description = "Graph and mesh/hypergraph partitioning, graph clustering, and sparse matrix ordering"; longDescription = '' From 0f237f6a34168552e55e079418385a072a978a81 Mon Sep 17 00:00:00 2001 From: qbisi Date: Fri, 26 Sep 2025 18:48:35 +0800 Subject: [PATCH 6/7] scotch: make ptscotch optional --- pkgs/by-name/mu/mumps/package.nix | 5 +++-- pkgs/by-name/sc/scotch/package.nix | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/mu/mumps/package.nix b/pkgs/by-name/mu/mumps/package.nix index a845e9175e63..f490a3ffcd01 100644 --- a/pkgs/by-name/mu/mumps/package.nix +++ b/pkgs/by-name/mu/mumps/package.nix @@ -20,6 +20,7 @@ assert withParmetis -> mpiSupport; assert withPtScotch -> mpiSupport; let + scotch' = scotch.override { inherit withPtScotch; }; profile = if mpiSupport then "debian.PAR" else "debian.SEQ"; LMETIS = toString ([ "-lmetis" ] ++ lib.optional withParmetis "-lparmetis"); LSCOTCH = toString ( @@ -78,7 +79,7 @@ stdenv.mkDerivation (finalAttrs: { "LIBEXT_SHARED=.dylib" ] ++ [ - "ISCOTCH=-I${lib.getDev scotch}/include" + "ISCOTCH=-I${lib.getDev scotch'}/include" "LMETIS=${LMETIS}" "LSCOTCH=${LSCOTCH}" "ORDERINGSF=${ORDERINGSF}" @@ -115,7 +116,7 @@ stdenv.mkDerivation (finalAttrs: { blas lapack metis - scotch + scotch' ]; doInstallCheck = true; diff --git a/pkgs/by-name/sc/scotch/package.nix b/pkgs/by-name/sc/scotch/package.nix index 2173f79902a4..5e586bab1b66 100644 --- a/pkgs/by-name/sc/scotch/package.nix +++ b/pkgs/by-name/sc/scotch/package.nix @@ -10,6 +10,7 @@ xz, zlib, mpi, + withPtScotch ? false, testers, }: @@ -33,6 +34,7 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) + (lib.cmakeBool "BUILD_PTSCOTCH" withPtScotch) ]; nativeBuildInputs = [ @@ -48,7 +50,7 @@ stdenv.mkDerivation (finalAttrs: { zlib ]; - propagatedBuildInputs = [ + propagatedBuildInputs = lib.optionals withPtScotch [ mpi ]; From c1601a2afa8b504a7e5ec693f8d54eba59f2d613 Mon Sep 17 00:00:00 2001 From: qbisi Date: Fri, 26 Sep 2025 19:16:15 +0800 Subject: [PATCH 7/7] scotch: install *metis.h to subdirectory SCOTCH has compatibility headers/libraries for the MeTiS/ParMeTiS interface. However, the header files "metis.h" and "parmetis.h" might cause conflict with exsiting metis/parmetis packages. Hence move them to subdirectory. --- pkgs/by-name/mu/mumps/package.nix | 18 ++++++++---------- pkgs/by-name/sc/scotch/package.nix | 12 ++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pkgs/by-name/mu/mumps/package.nix b/pkgs/by-name/mu/mumps/package.nix index f490a3ffcd01..d536e153cd37 100644 --- a/pkgs/by-name/mu/mumps/package.nix +++ b/pkgs/by-name/mu/mumps/package.nix @@ -108,16 +108,14 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional mpiSupport mpi ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; - # Parmetis should be placed before scotch to avoid conflict of header file "parmetis.h" - buildInputs = - lib.optional withParmetis parmetis - ++ lib.optional mpiSupport scalapack - ++ [ - blas - lapack - metis - scotch' - ]; + buildInputs = [ + blas + lapack + metis + scotch' + ] + ++ lib.optional mpiSupport scalapack + ++ lib.optional withParmetis parmetis; doInstallCheck = true; diff --git a/pkgs/by-name/sc/scotch/package.nix b/pkgs/by-name/sc/scotch/package.nix index 5e586bab1b66..9fafe1d1da77 100644 --- a/pkgs/by-name/sc/scotch/package.nix +++ b/pkgs/by-name/sc/scotch/package.nix @@ -35,6 +35,10 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) (lib.cmakeBool "BUILD_PTSCOTCH" withPtScotch) + # Prefix Scotch version of MeTiS routines + (lib.cmakeBool "SCOTCH_METIS_PREFIX" true) + # building tests is broken with SCOTCH_METIS_PREFIX enabled in 7.0.9 + (lib.cmakeBool "ENABLE_TESTS" false) ]; nativeBuildInputs = [ @@ -63,6 +67,14 @@ stdenv.mkDerivation (finalAttrs: { }; }; + # SCOTCH provide compatibility with Metis/Parmetis interface. + # We install the metis compatible headers to subdirectory to + # avoid conflict with metis/parmetis. + postFixup = '' + mkdir -p $dev/include/scotch + mv $dev/include/{*metis,metisf}.h $dev/include/scotch + ''; + meta = { description = "Graph and mesh/hypergraph partitioning, graph clustering, and sparse matrix ordering"; longDescription = ''