summary refs log tree commit diff
path: root/pkgs/applications/misc/crow-translate/default.nix
blob: c73094497319432f55bec51699fd30613d683af8 (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
{ lib
, mkDerivation
, nix-update-script
, fetchFromGitHub
, substituteAll
, cmake
, extra-cmake-modules
, qttools
, leptonica
, tesseract4
, qtmultimedia
, qtx11extras
, qttranslations
}:
let
  singleapplication = fetchFromGitHub {
    owner = "itay-grudev";
    repo = "SingleApplication";
    rev = "v3.2.0";
    sha256 = "0w3z97dcqcz3bf7w6fja4smkafmx9kvhzb9px4k2nfmmyxh4yfma";
  };
  qtaskbarcontrol = fetchFromGitHub {
    owner = "Skycoder42";
    repo = "QTaskbarControl";
    rev = "2.0.2";
    sha256 = "0iymcvq3pv07fs9l4kh6hi1igqr7957iqndhsmg9fqkalf8nqyad";
  };
  qhotkey = fetchFromGitHub {
    owner = "Skycoder42";
    repo = "QHotkey";
    rev = "1.4.2";
    sha256 = "0391fkqrxqmzpvms4rk06aq05l308k6sadp6y3czq0gx2kng8mn9";
  };
  qonlinetranslator = fetchFromGitHub {
    owner = "crow-translate";
    repo = "QOnlineTranslator";
    rev = "df89083d2f680a8f856b1df00b8846f995cf1fae";
    sha256 = "sha256-I64KGInnYd/QdI5kANJERsF95wMvRlr8kgQhUqXXN/0=";
  };
  circleflags = fetchFromGitHub {
    owner = "HatScripts";
    repo = "circle-flags";
    rev = "v2.3.0";
    sha256 = "sha256-KabmewF1Xf/1JQuzolrlRyLJR8O5j+/iT+29/QtOQVE=";
  };
  fluent = fetchFromGitHub {
    owner = "vinceliuice";
    repo = "Fluent-icon-theme";
    rev = "2021-08-15";
    sha256 = "sha256-uBu0vbKfhhnPKGwrnSBjPwS9ncH1iAlmeefAcpckOm4=";
  };
in
mkDerivation rec {
  pname = "crow-translate";
  version = "2.8.7";

  src = fetchFromGitHub {
    owner = "crow-translate";
    repo = pname;
    rev = version;
    sha256 = "sha256-0bq9itbFyzdOhdNuUtdCYLTCIhc91MM+YRhJgXC5PPw=";
  };

  patches = [
    (substituteAll {
      src = ./dont-fetch-external-libs.patch;
      inherit singleapplication qtaskbarcontrol qhotkey qonlinetranslator circleflags fluent;
    })
    (substituteAll {
      # See https://github.com/NixOS/nixpkgs/issues/86054
      src = ./fix-qttranslations-path.patch;
      inherit qttranslations;
    })
  ];

  postPatch = ''
    cp -r ${circleflags}/flags/* data/icons
    cp -r ${fluent}/src/* data/icons
  '';

  nativeBuildInputs = [ cmake extra-cmake-modules qttools ];

  buildInputs = [ leptonica tesseract4 qtmultimedia qtx11extras ];

  postInstall = ''
    substituteInPlace $out/share/applications/io.crow_translate.CrowTranslate.desktop \
      --replace "Exec=qdbus" "Exec=${lib.getBin qttools}/bin/qdbus"
  '';

  passthru = {
    updateScript = nix-update-script {
      attrPath = pname;
    };
  };

  meta = with lib; {
    description = "A simple and lightweight translator that allows to translate and speak text using Google, Yandex and Bing";
    homepage = "https://crow-translate.github.io/";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ sikmir ];
    platforms = platforms.linux;
  };
}