about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/misc/cobang/default.nix
blob: a1430a8b5e3965ca41fff16d6108c20c16aeeaa0 (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
{ lib
, buildPythonApplication
, fetchFromGitHub
, wrapGAppsHook
, atk
, gdk-pixbuf
, gobject-introspection
, gtk3
, gst-plugins-good
, libhandy
, librsvg
, networkmanager
, pango
, gst-python
, kiss-headers
, logbook
, pillow
, poetry-core
, pygobject3
, python
, python-zbar
, requests
, single-version
, pytestCheckHook }:

buildPythonApplication rec {
  pname = "cobang";
  version = "0.9.6";
  format = "pyproject";

  src = fetchFromGitHub {
    owner = "hongquan";
    repo = "CoBang";
    rev = "v${version}";
    sha256 = "sha256-YcXQ2wAgFSsJEqcaDQotpX1put4pQaF511kwq/c2yHw=";
  };

  patches = [
    ./0001-Poetry-core-and-pillow-9.patch
  ];

  nativeBuildInputs = [
    gobject-introspection
    wrapGAppsHook
  ];

  propagatedBuildInputs = [
    gst-python
    kiss-headers
    logbook
    pillow
    poetry-core
    pygobject3
    python-zbar
    requests
    single-version
  ];

  buildInputs = [
    atk
    gdk-pixbuf
    # Needed to detect namespaces
    gobject-introspection
    gst-plugins-good
    libhandy
    networkmanager
    pango
  ];

  nativeCheckInputs = [
    pytestCheckHook
  ];

  # Wrapping this manually for SVG recognition
  dontWrapGApps = true;

  postInstall = ''
    # Needed by the application
    cp -R data $out/${python.sitePackages}/

    # Icons and applications
    install -Dm 644 $out/${python.sitePackages}/data/vn.hoabinh.quan.CoBang.svg -t $out/share/pixmaps/
    install -Dm 644 $out/${python.sitePackages}/data/vn.hoabinh.quan.CoBang.desktop -t $out/share/applications/
    substituteInPlace $out/share/applications/vn.hoabinh.quan.CoBang.desktop \
      --replace "Exec=" "Exec=$out/bin/"
  '';

  preFixup = ''
    wrapProgram $out/bin/cobang \
      ''${gappsWrapperArgs[@]} \
      --prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
      --set GDK_PIXBUF_MODULE_FILE "${librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
  '';

  meta = with lib; {
    description = "A QR code scanner desktop app for Linux";
    homepage = "https://github.com/hongquan/CoBang";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ wolfangaukang ];
    platforms = [ "x86_64-linux" ];
  };
}