about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/audio/osdlyrics/default.nix
blob: 15d6aeee10dd4647a9296bf9a192b3b29f3121bc (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
{ lib
, stdenv
, fetchFromGitHub

, autoreconfHook
, pkg-config
, intltool

, glib
, gtk2
, dbus-glib
, libappindicator-gtk2
, libnotify
, python3
, runtimeShell
}:

stdenv.mkDerivation rec {
  pname = "osdlyrics";
  version = "0.5.14";

  src = fetchFromGitHub {
    owner = "osdlyrics";
    repo = "osdlyrics";
    rev = version;
    sha256 = "sha256-NVUQLmddXnpryt1AuHSwgPnWkgxWMBNJac09TJ12Yzo=";
  };

  nativeBuildInputs = [
    autoreconfHook
    pkg-config
    intltool
  ];

  buildInputs = [
    glib
    gtk2
    dbus-glib
    libappindicator-gtk2
    libnotify
    python3.pkgs.wrapPython
    (python3.withPackages (pp: with pp; [
      chardet
      dbus-python
      future
      pycurl
      pygobject3
    ]))
  ];

  postFixup = ''
    extractExecLine() {
      serviceFile=$1
      program=$2

      execLine=$(grep --only-matching --perl-regexp 'Exec=\K(.+)' "$serviceFile")
      echo "#!${runtimeShell}" > "$program"
      echo "exec $execLine" >> "$program"
      chmod +x "$program"

      substituteInPlace "$serviceFile" \
        --replace "Exec=$execLine" "Exec=$program"
    }

    # Extract the exec line into a separate program so that it can be wrapped.
    mkdir -p "$out/libexec/osdlyrics/"
    for svcFile in "$out/share/dbus-1/services"/*; do
      svc=$(basename "$svcFile" ".service")
      if grep "python" "$svcFile"; then
        extractExecLine "$svcFile" "$out/libexec/osdlyrics/$svc"
      fi
    done

    for p in "$out/bin/osdlyrics-create-lyricsource" "$out/bin/osdlyrics-daemon" "$out/libexec/osdlyrics"/*; do
      wrapProgram "$p" \
        --prefix PYTHONPATH : "$out/${python3.sitePackages}"
    done
  '';

  meta = with lib; {
    description = "Standalone lyrics fetcher/displayer";
    homepage = "https://github.com/osdlyrics/osdlyrics";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ ];
    platforms = platforms.linux;
  };
}