summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pystray/default.nix
blob: ad99775b980c18509c55c93d0bb0605d16806628 (plain)
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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch,
  gobject-introspection,
  setuptools,
  pillow,
  six,
  pygobject3,
  gtk3,
  stdenv,
  xlib,
  libayatana-appindicator,
  pyobjc-framework-Quartz,
  xvfb-run,
  pytest,
}:

buildPythonPackage rec {
  pname = "pystray";
  version = "0.19.5";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "moses-palmer";
    repo = "pystray";
    rev = "v${version}";
    hash = "sha256-CZhbaXwKFrRBEomzfFPMQdMkTOl5lbgI64etfDRiRu4=";
  };

  patches = [
    # fix test_menu_construct_from_none test case
    # https://github.com/moses-palmer/pystray/pull/133
    (fetchpatch {
      url = "https://github.com/moses-palmer/pystray/commit/813007e3034d950d93a2f3e5b029611c3c9c98ad.patch";
      hash = "sha256-m2LfZcWXSfgxb73dac21VDdMDVz3evzcCz5QjdnfM1U=";
    })
  ];

  postPatch = ''
    substituteInPlace setup.py \
      --replace-fail "'sphinx >=1.3.1'" ""
  '';

  nativeBuildInputs = [
    gobject-introspection
    setuptools
  ];

  propagatedBuildInputs = [
    pillow
    six
    pygobject3
    gtk3
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    xlib
    libayatana-appindicator
  ]
  ++ lib.optionals stdenv.isDarwin [ pyobjc-framework-Quartz ];

  nativeCheckInputs = [ pytest ] ++ lib.optionals stdenv.hostPlatform.isLinux [ xvfb-run ];

  checkPhase = ''
    runHook preCheck

    ${lib.optionalString stdenv.hostPlatform.isLinux "xvfb-run -s '-screen 0 800x600x24' "}pytest tests/menu_descriptor_tests.py

    runHook postCheck
  '';

  meta = {
    homepage = "https://github.com/moses-palmer/pystray";
    description = "This library allows you to create a system tray icon";
    license = with lib.licenses; [
      gpl3Plus
      lgpl3Plus
    ];
    platforms = lib.platforms.all;
    maintainers = with lib.maintainers; [ jojosch ];
  };
}