about summary refs log tree commit diff
path: root/pkgs/by-name/wt/wtwitch/package.nix
blob: 73bfe1c3fd6265af94f33c546ef7e68087836010 (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
{ bash
, coreutils-prefixed
, curl
, fetchFromGitHub
, gnused
, gnugrep
, installShellFiles
, jq
, lib
, makeWrapper
, mplayer
, mpv
, procps
, scdoc
, stdenv
, streamlink
, vlc
}:

stdenv.mkDerivation rec {
  pname = "wtwitch";
  version = "2.6.3";

  src = fetchFromGitHub {
    owner = "krathalan";
    repo = pname;
    rev = version;
    hash = "sha256-2YLBuxGwGkav3zB2qMqM6yRXf7ZLqgULoJV4s5p+hSw=";
  };

  # hardcode SCRIPT_NAME because #150841
  postPatch = ''
    substituteInPlace src/wtwitch --replace 'readonly SCRIPT_NAME="''${0##*/}"' 'readonly SCRIPT_NAME="wtwitch"'
  '';

  buildPhase = ''
    scdoc < src/wtwitch.1.scd > wtwitch.1
  '';

  nativeBuildInputs = [ scdoc installShellFiles makeWrapper ];

  installPhase = ''
    installManPage wtwitch.1
    installShellCompletion --cmd wtwitch \
      --bash src/wtwitch-completion.bash \
      --zsh src/_wtwitch
    install -Dm755 src/wtwitch $out/bin/wtwitch
    wrapProgram $out/bin/wtwitch \
      --set-default LANG en_US.UTF-8 \
      --prefix PATH : ${lib.makeBinPath (lib.optionals stdenv.hostPlatform.isLinux [ vlc ] ++ [
        bash
        coreutils-prefixed
        curl
        gnused
        gnugrep
        jq
        mplayer
        mpv
        procps
        streamlink
      ])}
  '';

  meta = with lib; {
    description = "Terminal user interface for Twitch";
    homepage = "https://github.com/krathalan/wtwitch";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ urandom ];
    platforms = platforms.all;
    mainProgram = "wtwitch";
  };
}