Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / science / chemistry / pymol / default.nix
blob155d521549e3bf4abcdacaed9f5b91e5b178fc84
1 { stdenv
2 , lib
3 , fetchFromGitHub
4 , makeDesktopItem
5 , python3
6 , python3Packages
7 , netcdf
8 , glew
9 , glm
10 , libpng
11 , libxml2
12 , freetype
13 , msgpack
14 , qt5
16 let
17   pname = "pymol";
18   description = "A Python-enhanced molecular graphics tool";
20   desktopItem = makeDesktopItem {
21     name = pname;
22     exec = pname;
23     desktopName = "PyMol Molecular Graphics System";
24     genericName = "Molecular Modeler";
25     comment = description;
26     icon = pname;
27     mimeTypes = [
28       "chemical/x-pdb"
29       "chemical/x-mdl-molfile"
30       "chemical/x-mol2"
31       "chemical/seq-aa-fasta"
32       "chemical/seq-na-fasta"
33       "chemical/x-xyz"
34       "chemical/x-mdl-sdf"
35     ];
36     categories = [ "Graphics" "Education" "Science" "Chemistry" ];
37   };
39 python3Packages.buildPythonApplication rec {
40   inherit pname;
41   version = "2.5.0";
42   src = fetchFromGitHub {
43     owner = "schrodinger";
44     repo = "pymol-open-source";
45     rev = "v${version}";
46     sha256 = "sha256-JdsgcVF1w1xFPZxVcyS+GcWg4a1Bd4SvxFOuSdlz9SM=";
47   };
49   nativeBuildInputs = [ qt5.wrapQtAppsHook ];
50   buildInputs = [ python3Packages.numpy python3Packages.pyqt5 glew glm libpng libxml2 freetype msgpack netcdf ];
51   env.NIX_CFLAGS_COMPILE = "-I ${libxml2.dev}/include/libxml2";
52   hardeningDisable = [ "format" ];
54   installPhase = ''
55     python setup.py install --home="$out"
56     runHook postInstall
57   '';
59   postInstall = with python3Packages; ''
60     wrapProgram $out/bin/pymol \
61       --prefix PYTHONPATH : ${lib.makeSearchPathOutput "lib" python3.sitePackages [ pyqt5 pyqt5.pyqt5_sip ]}
63     mkdir -p "$out/share/icons/"
64     ln -s ../../lib/python/pymol/pymol_path/data/pymol/icons/icon2.svg "$out/share/icons/pymol.svg"
65     cp -r "${desktopItem}/share/applications/" "$out/share/"
66   '';
68   preFixup = ''
69     wrapQtApp "$out/bin/pymol"
70   '';
72   meta = with lib; {
73     inherit description;
74     homepage = "https://www.pymol.org/";
75     license = licenses.mit;
76     maintainers = with maintainers; [ samlich ];
77   };