Commit 60c4a999 authored by Gaetan Lepage's avatar Gaetan Lepage
Browse files

sundials: cleanup

parent b49a4c98
Loading
Loading
Loading
Loading
+28 −23
Original line number Diff line number Diff line
{
  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"
    )
    (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;
  };
}
})