at master 6.3 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 fetchzip, 6 applyPatches, 7 replaceVars, 8 cmake, 9 comic-neue, 10 boost, 11 catch2_3, 12 cairo, 13 eigen, 14 python, 15 rapidjson, 16 maeparser, 17 coordgenlibs, 18 numpy, 19 pandas, 20 pillow, 21}: 22let 23 external = { 24 avalon = fetchFromGitHub { 25 owner = "rdkit"; 26 repo = "ava-formake"; 27 rev = "AvalonToolkit_2.0.5-pre.3"; 28 hash = "sha256-2MuFZgRIHXnkV7Nc1da4fa7wDx57VHUtwLthrmjk+5o="; 29 }; 30 chemdraw = fetchFromGitHub { 31 owner = "Glysade"; 32 repo = "chemdraw"; 33 tag = "v1.0.10"; 34 hash = "sha256-ee2Oxvo2d7Yb59lN0zkrbFqy/3rOvVLo6qdS+f23wVQ="; 35 }; 36 yaehmop = applyPatches { 37 src = fetchFromGitHub { 38 owner = "greglandrum"; 39 repo = "yaehmop"; 40 rev = "v2025.03.1"; 41 hash = "sha256-rhR7Ev+9Fk/Ks7R2x2SjWu1L/48a4zHDHUBohx1Dw/M="; 42 }; 43 44 # Compatibility with CMake < 3.5 has been removed from CMake. 45 postPatch = '' 46 substituteInPlace tightbind/CMakeLists.txt \ 47 --replace-fail \ 48 "cmake_minimum_required(VERSION 3.0)" \ 49 "cmake_minimum_required(VERSION 3.5)" 50 ''; 51 }; 52 freesasa = fetchFromGitHub { 53 owner = "mittinatten"; 54 repo = "freesasa"; 55 rev = "2.0.3"; 56 hash = "sha256-7E+imvfDAJFnXQRWb5hNaSu+Xrf9NXeIKc9fl+o3yHQ="; 57 }; 58 pubchem-align3d = fetchFromGitHub { 59 owner = "ncbi"; 60 repo = "pubchem-align3d"; 61 rev = "daefab3dd0c90ca56da9d3d5e375fe4d651e6be3"; 62 hash = "sha256-tQB4wqza9rlSoy4Uj9bA99ddawjxGyN9G7DYbcv/Qdo="; 63 }; 64 better_enums = fetchFromGitHub { 65 owner = "aantron"; 66 repo = "better-enums"; 67 tag = "0.11.3"; 68 hash = "sha256-UYldCOkRTySc78oEOJzgoY9h2lB386W/D5Rz3KjVCO8="; 69 }; 70 # We cannot use the inchi from nixpkgs as the version is too old 71 inchi = fetchzip { 72 url = "https://github.com/IUPAC-InChI/InChI/releases/download/v1.07.3/INCHI-1-SRC.zip"; 73 hash = "sha256-TUC2175HifB63EfSsg/ixA3wYzAxsvUnY6ZyNjVR/Fc="; 74 }; 75 }; 76 boost' = boost.override { enableNumpy = true; }; 77in 78buildPythonPackage rec { 79 pname = "rdkit"; 80 version = "2025.03.6"; 81 pyproject = false; 82 83 src = 84 let 85 versionTag = lib.replaceStrings [ "." ] [ "_" ] version; 86 in 87 fetchFromGitHub { 88 owner = "rdkit"; 89 repo = "rdkit"; 90 tag = "Release_${versionTag}"; 91 hash = "sha256-DqnwfT+lX7OnArIcFlCBrDl+QDmNpbPO9u7OGwu8fJo="; 92 }; 93 94 unpackPhase = '' 95 cp -r $src/* . 96 find . -type d -exec chmod +w {} + 97 98 mkdir External/AvalonTools/avalon 99 # In buildPhase, CMake patches the file in this directory 100 # see https://github.com/rdkit/rdkit/pull/5928 101 cp -r ${external.avalon}/* External/AvalonTools/avalon 102 103 mkdir External/ChemDraw/chemdraw 104 cp -r ${external.chemdraw}/* External/ChemDraw/chemdraw/ 105 chmod -R +w External/ChemDraw/chemdraw 106 107 mkdir External/YAeHMOP/yaehmop 108 ln -s ${external.yaehmop}/* External/YAeHMOP/yaehmop 109 110 mkdir External/FreeSASA/freesasa 111 cp -r ${external.freesasa}/* External/FreeSASA/freesasa 112 chmod +w External/FreeSASA/freesasa/src 113 cp External/FreeSASA/freesasa2.c External/FreeSASA/freesasa/src 114 115 mkdir External/pubchem_shape/pubchem-align3d 116 cp -r ${external.pubchem-align3d}/* External/pubchem_shape/pubchem-align3d 117 118 mkdir External/INCHI-API/src 119 ln -s ${external.inchi}/* External/INCHI-API/src 120 121 ln -s ${rapidjson} External/rapidjson-1.1.0 122 ln -s ${comic-neue}/share/fonts/truetype/ComicNeue-Regular.ttf Data/Fonts/ 123 ''; 124 125 patches = [ 126 (replaceVars ./dont-fetch-better-enums.patch { 127 inherit (external) better_enums; 128 }) 129 ]; 130 131 # Prevent linking to libpython which fails on darwin with: 132 # Undefined symbols for architecture arm64 133 # Reverts https://github.com/rdkit/rdkit/commit/470df8cd2fab78d64ef1dd254576097b651c3dd9 134 postPatch = '' 135 substituteInPlace \ 136 CMakeLists.txt \ 137 External/pubchem_shape/Wrap/CMakeLists.txt \ 138 --replace-fail \ 139 "find_package(Python3 COMPONENTS Interpreter Development.Module NumPy" \ 140 "find_package(Python3 COMPONENTS Interpreter Development NumPy" \ 141 ''; 142 143 nativeBuildInputs = [ cmake ]; 144 145 buildInputs = [ 146 boost' 147 cairo 148 catch2_3 149 coordgenlibs 150 eigen 151 maeparser 152 ]; 153 154 dependencies = [ 155 numpy 156 pandas 157 pillow 158 ]; 159 160 hardeningDisable = [ "format" ]; # required by yaehmop 161 162 cmakeFlags = [ 163 (lib.cmakeBool "Boost_NO_BOOST_CMAKE" true) 164 (lib.cmakeBool "Boost_NO_SYSTEM_PATHS" true) 165 (lib.cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) # fails to find libs in pythonImportsCheckPhase otherwise 166 (lib.cmakeBool "RDK_BUILD_AVALON_SUPPORT" true) 167 (lib.cmakeBool "RDK_BUILD_CAIRO_SUPPORT" true) 168 (lib.cmakeBool "RDK_BUILD_COORDGEN_SUPPORT" true) 169 (lib.cmakeBool "RDK_BUILD_CPP_TESTS" true) 170 (lib.cmakeBool "RDK_BUILD_FREESASA_SUPPORT" true) 171 (lib.cmakeBool "RDK_BUILD_INCHI_SUPPORT" true) 172 (lib.cmakeBool "RDK_BUILD_MAEPARSER_SUPPORT" true) 173 (lib.cmakeBool "RDK_BUILD_THREADSAFE_SSS" true) 174 (lib.cmakeBool "RDK_BUILD_XYZ2MOL_SUPPORT" true) 175 (lib.cmakeBool "RDK_BUILD_YAEHMOP_SUPPORT" true) 176 (lib.cmakeBool "RDK_INSTALL_INTREE" false) 177 (lib.cmakeBool "RDK_INSTALL_STATIC_LIBS" false) 178 (lib.cmakeBool "RDK_TEST_MULTITHREADED" true) 179 (lib.cmakeBool "RDK_USE_FLEXBISON" false) 180 (lib.cmakeBool "RDK_USE_URF" false) 181 (lib.cmakeFeature "AVALONTOOLS_DIR" "avalon") 182 (lib.cmakeFeature "FREESASA_SRC_DIR" "freesasa") 183 (lib.cmakeFeature "maeparser_DIR" "${maeparser}/lib/cmake") 184 (lib.cmakeFeature "coordgen_DIR" "${coordgenlibs}/lib/cmake") 185 ]; 186 187 checkPhase = '' 188 export QT_QPA_PLATFORM='offscreen' 189 export RDBASE=$(realpath ..) 190 export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH" 191 (cd $RDBASE/rdkit/Chem && python $RDBASE/rdkit/TestRunner.py test_list.py) 192 ''; 193 194 pythonImportsCheck = [ 195 "rdkit" 196 "rdkit.Chem" 197 "rdkit.Chem.AllChem" 198 "rdkit.Chem.rdDetermineBonds" 199 ]; 200 201 meta = { 202 description = "Open source toolkit for cheminformatics"; 203 maintainers = with lib.maintainers; [ 204 rmcgibbo 205 natsukium 206 ]; 207 license = lib.licenses.bsd3; 208 homepage = "https://www.rdkit.org"; 209 changelog = "https://github.com/rdkit/rdkit/releases/tag/${src.tag}"; 210 }; 211}