Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / video / popcorntime / default.nix
bloba1217177296695a819b035484e49b06e8049b96f
1 { autoPatchelfHook
2 , fetchurl
3 , gcc-unwrapped
4 , gsettings-desktop-schemas
5 , gtk3
6 , lib
7 , makeDesktopItem
8 , makeWrapper
9 , nwjs
10 , stdenv
11 , unzip
12 , udev
13 , wrapGAppsHook
14 , copyDesktopItems
17 stdenv.mkDerivation rec {
18   pname = "popcorntime";
19   version = "0.4.9";
21   src = fetchurl {
22     url = "https://github.com/popcorn-official/popcorn-desktop/releases/download/v${version}/Popcorn-Time-${version}-linux64.zip";
23     sha256 = "sha256-cbKL5bgweZD/yfi/8KS0L7Raha8PTHqIm4qSPFidjUc=";
24   };
26   nativeBuildInputs = [
27     autoPatchelfHook
28     makeWrapper
29     unzip
30     wrapGAppsHook
31     copyDesktopItems
32   ];
34   buildInputs = [
35     gcc-unwrapped
36     gsettings-desktop-schemas
37     gtk3
38     nwjs
39     udev
40   ];
42   sourceRoot = ".";
44   dontWrapGApps = true;
45   dontUnpack = true;
47   makeWrapperArgs = [
48     "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ gcc-unwrapped.lib gtk3 udev ]}"
49     "--prefix PATH : ${lib.makeBinPath [ stdenv.cc ]}"
50   ];
52   desktopItem = makeDesktopItem {
53       name = pname;
54       exec = pname;
55       icon = pname;
56       comment = meta.description;
57       genericName = meta.description;
58       type = "Application";
59       desktopName = "Popcorn-Time";
60       categories = [ "Video" "AudioVideo" ];
61     };
63   # Extract and copy executable in $out/bin
64   installPhase = ''
65     mkdir -p $out/share/applications $out/bin $out/opt/bin $out/share/icons/hicolor/scalable/apps/
66     # we can't unzip it in $out/lib, because nw.js will start with
67     # an empty screen. Therefore it will be unzipped in a non-typical
68     # folder and symlinked.
69     unzip -q $src -d $out/opt/popcorntime
71     ln -s $out/opt/popcorntime/Popcorn-Time $out/bin/popcorntime
73     ln -s $out/opt/popcorntime/src/app/images/icon.png $out/share/icons/hicolor/scalable/apps/popcorntime.png
75     ln -s ${desktopItem}/share/applications/popcorntime.desktop $out/share/applications/popcorntime.desktop
76   '';
78   # GSETTINGS_SCHEMAS_PATH is not set in installPhase
79   preFixup = ''
80     wrapProgram $out/bin/popcorntime \
81       ''${makeWrapperArgs[@]} \
82       ''${gappsWrapperArgs[@]}
83   '';
85   meta = with lib; {
86     homepage = "https://github.com/popcorn-official/popcorn-desktop";
87     description = "An application that streams movies and TV shows from torrents";
88     platforms = [ "x86_64-linux" ];
89     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
90     license = lib.licenses.gpl3;
91     maintainers = with maintainers; [ onny ];
92   };