From 60c4a999bad74bb237f72b2826d6a3eed2dcfff6 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 17 Oct 2025 22:08:38 +0000 Subject: [PATCH] sundials: cleanup --- pkgs/by-name/su/sundials/package.nix | 51 +++++++++++++++------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/pkgs/by-name/su/sundials/package.nix b/pkgs/by-name/su/sundials/package.nix index aea189af3a20..29ca0a19b99a 100644 --- a/pkgs/by-name/su/sundials/package.nix +++ b/pkgs/by-name/su/sundials/package.nix @@ -1,18 +1,19 @@ { lib, stdenv, + fetchFromGitHub, cmake, - fetchurl, + gfortran, python3, blas, lapack, - gfortran, suitesparse, + nix-update-script, lapackSupport ? true, kluSupport ? true, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "sundials"; version = "7.5.0"; @@ -21,9 +22,11 @@ stdenv.mkDerivation rec { "examples" ]; - src = fetchurl { - url = "https://github.com/LLNL/sundials/releases/download/v${version}/sundials-${version}.tar.gz"; - hash = "sha256-CJrGWVB973OLemW1dP/jqQDThWnjMj2XCevtPkRa3sw="; + src = fetchFromGitHub { + owner = "LLNL"; + repo = "sundials"; + tag = "v${finalAttrs.version}"; + hash = "sha256-ZyUTFaMEbfNtR9oGIy0fQ+qQwb3hQ7CxTv9IevkeidE="; }; nativeBuildInputs = [ @@ -51,34 +54,36 @@ stdenv.mkDerivation rec { ]; cmakeFlags = [ - "-DEXAMPLES_INSTALL_PATH=${placeholder "examples"}/share/examples" + (lib.cmakeFeature "EXAMPLES_INSTALL_PATH" "${placeholder "examples"}/share/examples") ] ++ lib.optionals lapackSupport [ - "-DENABLE_LAPACK=ON" - "-DLAPACK_LIBRARIES=${lapack}/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary}" + (lib.cmakeBool "ENABLE_LAPACK" true) + (lib.cmakeFeature "LAPACK_LIBRARIES" "${lapack}/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary}") ] ++ lib.optionals kluSupport [ - "-DENABLE_KLU=ON" - "-DKLU_INCLUDE_DIR=${suitesparse.dev}/include" - "-DKLU_LIBRARY_DIR=${suitesparse}/lib" + (lib.cmakeBool "ENABLE_KLU" true) + (lib.cmakeFeature "KLU_INCLUDE_DIR" "${lib.getDev suitesparse}/include") + (lib.cmakeFeature "KLU_LIBRARY_DIR" "${suitesparse}/lib") ] ++ [ - ( - # Use the correct index type according to lapack and blas used. They are - # already supposed to be compatible but we check both for extra safety. 64 - # should be the default but we prefer to be explicit, for extra safety. - if blas.isILP64 then "-DSUNDIALS_INDEX_SIZE=64" else "-DSUNDIALS_INDEX_SIZE=32" - ) + # Use the correct index type according to lapack and blas used. They are + # already supposed to be compatible but we check both for extra safety. 64 + # should be the default but we prefer to be explicit, for extra safety. + (lib.cmakeFeature "SUNDIALS_INDEX_SIZE" (toString (if blas.isILP64 then 64 else 32))) ]; doCheck = true; checkTarget = "test"; - meta = with lib; { + passthru.updateScript = nix-update-script { }; + + meta = { description = "Suite of nonlinear differential/algebraic equation solvers"; homepage = "https://computing.llnl.gov/projects/sundials"; - platforms = platforms.all; - maintainers = with maintainers; [ idontgetoutmuch ]; - license = licenses.bsd3; + downloadPage = "https://github.com/LLNL/sundials"; + changelog = "https://github.com/LLNL/sundials/releases/tag/v${finalAttrs.version}"; + platforms = lib.platforms.all; + maintainers = with lib.maintainers; [ idontgetoutmuch ]; + license = lib.licenses.bsd3; }; -} +})