From dc622dce817e33f40889186e25711dee4ed5d163 Mon Sep 17 00:00:00 2001 From: Alexander Kiselyov Date: Fri, 23 Aug 2024 14:04:49 +0300 Subject: [PATCH] petsc: removed default unfree dependencies --- pkgs/by-name/pe/petsc/package.nix | 79 ++++++++++++++----------------- 1 file changed, 36 insertions(+), 43 deletions(-) diff --git a/pkgs/by-name/pe/petsc/package.nix b/pkgs/by-name/pe/petsc/package.nix index a9cc4ace97a3..6683d59198ae 100644 --- a/pkgs/by-name/pe/petsc/package.nix +++ b/pkgs/by-name/pe/petsc/package.nix @@ -15,6 +15,7 @@ hdf5, metis, parmetis, + withParmetis ? false, pkg-config, p4est, zlib, # propagated by p4est but required by petsc @@ -36,7 +37,6 @@ stdenv.mkDerivation rec { }; inherit mpiSupport; - withp4est = petsc-withp4est; strictDeps = true; nativeBuildInputs = [ @@ -47,7 +47,7 @@ stdenv.mkDerivation rec { buildInputs = [ blas lapack - ] ++ lib.optional hdf5-support hdf5 ++ lib.optional withp4est p4est; + ] ++ lib.optional hdf5-support hdf5 ++ lib.optional petsc-withp4est p4est ++ lib.optionals withParmetis [ metis parmetis ]; prePatch = lib.optionalString stdenv.isDarwin '' substituteInPlace config/install.py \ @@ -60,49 +60,42 @@ stdenv.mkDerivation rec { # These messages contaminate test output, which makes the quicktest suite to fail. The patch adds filtering for these messages. patches = [ ./filter_mpi_warnings.patch ]; + configureFlags = [ + "--with-blas=1" + "--with-lapack=1" + "--with-scalar-type=${petsc-scalar-type}" + "--with-precision=${petsc-precision}" + "--with-mpi=${if mpiSupport then "1" else "0"}" + ] ++ lib.optionals mpiSupport [ + "--CC=mpicc" + "--with-cxx=mpicxx" + "--with-fc=mpif90" + ] ++ lib.optionals (mpiSupport && withParmetis) [ + "--with-metis=1" + "--with-metis-dir=${metis}" + "--with-parmetis=1" + "--with-parmetis-dir=${parmetis}" + ] ++ lib.optionals petsc-optimized [ + "--with-debugging=0" + "COPTFLAGS=-O3" + "FOPTFLAGS=-O3" + "CXXOPTFLAGS=-O3" + "CXXFLAGS=-O3" + ]; preConfigure = '' patchShebangs ./lib/petsc/bin - configureFlagsArray=( - $configureFlagsArray - ${ - if !mpiSupport then - '' - "--with-mpi=0" - '' - else - '' - "--CC=mpicc" - "--with-cxx=mpicxx" - "--with-fc=mpif90" - "--with-mpi=1" - "--with-metis=1" - "--with-metis-dir=${metis}" - "--with-parmetis=1" - "--with-parmetis-dir=${parmetis}" - '' - } - ${lib.optionalString withp4est '' - "--with-p4est=1" - "--with-zlib-include=${zlib.dev}/include" - "--with-zlib-lib=-L${zlib}/lib -lz" - ''} - ${lib.optionalString hdf5-support '' - "--with-hdf5=1" - "--with-hdf5-fortran-bindings=1" - "--with-hdf5-lib=-L${hdf5}/lib -lhdf5" - "--with-hdf5-include=${hdf5.dev}/include" - ''} - "--with-blas=1" - "--with-lapack=1" - "--with-scalar-type=${petsc-scalar-type}" - "--with-precision=${petsc-precision}" - ${lib.optionalString petsc-optimized '' - "--with-debugging=0" - COPTFLAGS='-O3' - FOPTFLAGS='-O3' - CXXOPTFLAGS='-O3' - CXXFLAGS='-O3' - ''} + '' + lib.optionalString petsc-withp4est '' + configureFlagsArray+=( + "--with-p4est=1" + "--with-zlib-include=${zlib.dev}/include" + "--with-zlib-lib=-L${zlib}/lib -lz" + ) + '' + lib.optionalString hdf5-support '' + configureFlagsArray+=( + "--with-hdf5=1" + "--with-hdf5-fortran-bindings=1" + "--with-hdf5-include=${hdf5.dev}/include" + "--with-hdf5-lib=-L${hdf5}/lib -lhdf5" ) '';