about summary refs log tree commit diff
path: root/pkgs/tools/bluetooth/blueberry/default.nix
blob: 63845045c06b6f23b37394d9219cecee62f20413 (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
{ stdenv
, lib
, fetchFromGitHub
, bluez-tools
, cinnamon
, gnome
, gobject-introspection
, libnotify
, pavucontrol
, python3Packages
, util-linux
, wrapGAppsHook
}:

stdenv.mkDerivation rec {
  pname = "blueberry";
  version = "1.4.8";

  src = fetchFromGitHub {
    owner = "linuxmint";
    repo = pname;
    rev = version;
    sha256 = "sha256-MyIjcTyKn1aC2th6fCOw4cIqrRKatk2s4QD5R9cm83A=";
  };

  nativeBuildInputs = [
    gobject-introspection
    python3Packages.wrapPython
    wrapGAppsHook
  ];

  buildInputs = [
    bluez-tools
    cinnamon.xapp
    gnome.gnome-bluetooth_1_0
    libnotify
    python3Packages.python
    util-linux
  ];

  pythonPath = with python3Packages; [
    dbus-python
    pygobject3
    setproctitle
  ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out
    cp -a etc usr/* $out

    # Fix paths
    substituteInPlace $out/bin/blueberry \
      --replace /usr/lib/blueberry $out/lib/blueberry
    substituteInPlace $out/bin/blueberry-tray \
      --replace /usr/lib/blueberry $out/lib/blueberry
    substituteInPlace $out/etc/xdg/autostart/blueberry-obex-agent.desktop \
      --replace /usr/lib/blueberry $out/lib/blueberry
    substituteInPlace $out/etc/xdg/autostart/blueberry-tray.desktop \
      --replace Exec=blueberry-tray Exec=$out/bin/blueberry-tray
    substituteInPlace $out/lib/blueberry/blueberry-obex-agent.py \
      --replace /usr/share $out/share
    substituteInPlace $out/lib/blueberry/blueberry-tray.py \
      --replace /usr/share $out/share
    substituteInPlace $out/lib/blueberry/blueberry.py \
      --replace '"bt-adapter"' '"${bluez-tools}/bin/bt-adapter"' \
      --replace /usr/bin/pavucontrol ${pavucontrol}/bin/pavucontrol \
      --replace /usr/lib/blueberry $out/lib/blueberry \
      --replace /usr/share $out/share
    substituteInPlace $out/lib/blueberry/rfkillMagic.py \
      --replace /usr/bin/rfkill ${util-linux}/bin/rfkill \
      --replace /usr/sbin/rfkill ${util-linux}/bin/rfkill \
      --replace /usr/lib/blueberry $out/lib/blueberry
    substituteInPlace $out/share/applications/blueberry.desktop \
      --replace Exec=blueberry Exec=$out/bin/blueberry

    glib-compile-schemas --strict $out/share/glib-2.0/schemas

    runHook postInstall
  '';

  dontWrapGApps = true;

  postFixup = ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
    wrapPythonProgramsIn $out/lib "$out $pythonPath"
  '';

  meta = with lib; {
    description = "Bluetooth configuration tool";
    homepage = "https://github.com/linuxmint/blueberry";
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ bobby285271 romildo ];
  };
}