about summary refs log tree commit diff
path: root/pkgs/applications/networking/geph/default.nix
blob: 2b7987fa1e46d664e741ab25d4138bfcfbb3c99b (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{ lib
, stdenvNoCC
, rustPlatform
, fetchFromGitHub
, buildNpmPackage
, perl
, pkg-config
, glib
, webkitgtk
, libappindicator-gtk3
, libayatana-appindicator
, cairo
, openssl
}:

let
  version = "4.7.8";
  geph-meta = with lib; {
    description = "A modular Internet censorship circumvention system designed specifically to deal with national filtering.";
    homepage = "https://geph.io";
    platforms = platforms.linux;
    maintainers = with maintainers; [ penalty1083 ];
  };
in
{
  cli = rustPlatform.buildRustPackage rec {
    pname = "geph4-client";
    inherit version;

    src = fetchFromGitHub {
      owner = "geph-official";
      repo = pname;
      rev = "v${version}";
      hash = "sha256-DVGbLyFgraQMSIUAqDehF8DqbnvcaeWbuLVgiSQY3KE=";
    };

    cargoHash = "sha256-uBq6rjUnKEscwhu60HEZffLvuXcArz+AiR52org+qKw=";

    nativeBuildInputs = [ perl ];

    meta = geph-meta // {
      license = with lib.licenses; [ gpl3Only ];
    };
  };

  gui = stdenvNoCC.mkDerivation rec {
    pname = "geph-gui";
    inherit version;

    src = fetchFromGitHub {
      owner = "geph-official";
      repo = "gephgui-pkg";
      rev = "85a55bfc2f4314d9c49608f252080696b1f8e2a9";
      hash = "sha256-id/sfaQsF480kUXg//O5rBIciuuhDuXY19FQe1E3OQs=";
      fetchSubmodules = true;
    };

    gephgui = buildNpmPackage {
      pname = "gephgui";
      inherit version src;

      sourceRoot = "source/gephgui-wry/gephgui";

      postPatch = "ln -s ${./package-lock.json} ./package-lock.json";

      npmDepsHash = "sha256-5y6zpMF4M56DiWVhMvjJGsYpVdlJSoWoWyPgLc7hJoo=";

      installPhase = ''
        runHook preInstall

        mkdir -p $out
        mv dist $out

        runHook postInstall
      '';
    };

    gephgui-wry = rustPlatform.buildRustPackage rec {
      pname = "gephgui-wry";
      inherit version src;

      sourceRoot = "source/gephgui-wry";

      cargoHash = "sha256-lidlUUfHXKPUlICdaVv/SFlyyWsZ7cYHyTJ3kkMn3L4=";

      nativeBuildInputs = [ pkg-config ];

      buildInputs = [
        glib
        webkitgtk
        libappindicator-gtk3
        libayatana-appindicator
        cairo
        openssl
      ];

      preBuild = ''
        ln -s ${gephgui}/dist ./gephgui
      '';
    };

    dontBuild = true;

    installPhase = ''
      install -Dt $out/bin ${gephgui-wry}/bin/gephgui-wry
      install -d $out/share/icons/hicolor
      for i in '16' '32' '64' '128' '256'
      do
        name=''${i}x''${i}
        dir=$out/share/icons/hicolor
        mkdir -p $dir
        mv flatpak/icons/$name $dir
      done
      install -Dt $out/share/applications flatpak/icons/io.geph.GephGui.desktop
      sed -i -e '/StartupWMClass/s/=.*/=gephgui-wry/' $out/share/applications/io.geph.GephGui.desktop
    '';

    meta = geph-meta // {
      license = with lib.licenses; [ unfree ];
    };
  };
}