about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/science/chemistry/apbs/default.nix
blob: ec8f8e7ffbf612b486b6e649281acc755e82e296 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{ lib
, stdenv
, fetchFromGitHub
, cmake
, blas
, superlu
, suitesparse
, python3
, libintl
, libiconv
}:
let
  # this is a fork version of fetk (http://www.fetk.org/)
  # which is maintained by apbs team
  fetk = stdenv.mkDerivation (finalAttrs: {
    pname = "fetk";
    version = "1.9.3";

    src = fetchFromGitHub {
      owner = "Electrostatics";
      repo = "fetk";
      rev = "refs/tags/${finalAttrs.version}";
      hash = "sha256-uFA1JRR05cNcUGaJj9IyGNONB2hU9IOBPzOj/HucNH4=";
    };

    nativeBuildInputs = [
      cmake
    ];

    cmakeFlags = [
      "-DBLAS_LIBRARIES=${blas}/lib"
      "-DBLA_STATIC=OFF"
      "-DBUILD_SUPERLU=OFF"
    ];

    env = lib.optionalAttrs stdenv.cc.isClang {
      NIX_CFLAGS_COMPILE = "-Wno-error=implicit-int";
    };

    buildInputs = [
      blas
      superlu
      suitesparse
    ];

    meta = with lib; {
      description = "Fork of the Finite Element ToolKit from fetk.org";
      homepage = "https://github.com/Electrostatics/FETK";
      changelog = "https://github.com/Electrostatics/FETK/releases/tag/${finalAttrs.version}";
      license = licenses.lgpl21Plus;
      maintainers = with maintainers; [ natsukium ];
      platforms = platforms.unix;
    };
  });
in
stdenv.mkDerivation (finalAttrs: {
  pname = "apbs";
  version = "3.4.1";

  src = fetchFromGitHub {
    owner = "Electrostatics";
    repo = "apbs";
    rev = "refs/tags/v${finalAttrs.version}";
    hash = "sha256-2DnHU9hMDl4OJBaTtcRiB+6R7gAeFcuOUy7aI63A3gQ=";
  };

  postPatch = ''
    # ImportFETK.cmake downloads source and builds fetk
    substituteInPlace CMakeLists.txt \
      --replace "include(ImportFETK)" "" \
      --replace 'import_fetk(''${FETK_VERSION})' ""

    # U was removed in python 3.11 because it had no effect
    substituteInPlace tools/manip/inputgen.py \
      --replace '"rU"' '"r"'
  '';

  nativeBuildInputs = [
    cmake
  ];

  buildInputs = [
    fetk
    suitesparse
    blas
    python3
  ] ++ lib.optionals stdenv.isDarwin [
    libintl
    libiconv
  ];

  cmakeFlags = [
    "-DPYTHON_VERSION=${python3.version}"
    "-DAPBS_LIBS=mc;maloc"
    "-DCMAKE_MODULE_PATH=${fetk}/share/fetk/cmake;"
    "-DENABLE_TESTS=1"
  ];

  env = lib.optionalAttrs stdenv.cc.isClang {
    NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-function-pointer-types";
  };

  doCheck = true;

  meta = with lib; {
    description = "Software for biomolecular electrostatics and solvation calculations";
    mainProgram = "apbs";
    homepage = "https://www.poissonboltzmann.org/";
    changelog = "https://github.com/Electrostatics/apbs/releases/tag/v${finalAttrs.version}";
    license = licenses.bsd3;
    maintainers = with maintainers; [ natsukium ];
    platforms = platforms.unix;
  };
})