summary refs log tree commit diff
path: root/pkgs/applications/video/popcorntime/default.nix
blob: e74c8e9a5a8db7cc071a66efc9fd323343f61cf3 (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
{ lib, stdenv, fetchurl, runCommand, makeWrapper, nwjs, zip }:

let
  version = "0.3.8-3";

  popcorntimePackage = stdenv.mkDerivation rec {
    name = "popcorntime-${version}";
    src = if stdenv.system == "x86_64-linux" then
        fetchurl {
          url = "http://get.popcorntime.io/build/Popcorn-Time-${version}-Linux-64.tar.xz";
          sha256 = "0q8c6m9majgv5a6hjl1b2ndmq4xx05zbarsydhqkivhh9aymvxgm";
        }
      else if stdenv.system == "i686-linux" then
        fetchurl {
          url = "https://get.popcorntime.io/build/Popcorn-Time-${version}-Linux-32.tar.xz";
          sha256 = "1dz1cp31qbwamm9pf8ydmzzhnb6d9z73bigdv3y74dgicz3dpr92";
        }
      else throw "Unsupported system ${stdenv.system}";

    sourceRoot = ".";

    buildInputs = [ zip ];

    buildPhase = ''
      rm Popcorn-Time install
      zip -r package.nw package.json src node_modules
      cat ${nwjs}/bin/nw package.nw > Popcorn-Time
      chmod 555 Popcorn-Time
    '';

    installPhase = ''
      mkdir -p $out
      cp -r * $out/
    '';

    dontPatchELF = true;
  };
in
  runCommand "popcorntime-${version}" {
    buildInputs = [ makeWrapper ];
    meta = with stdenv.lib; {
      homepage = http://popcorntime.io/;
      description = "An application that streams movies and TV shows from torrents";
      license = stdenv.lib.licenses.gpl3;
      platforms = platforms.linux;
      maintainers = with maintainers; [ bobvanderlinden ];
      broken = true;  # popcorntime.io is dead
    };
  }
  ''
    mkdir -p $out/bin
    makeWrapper ${popcorntimePackage}/Popcorn-Time $out/bin/popcorntime
  ''