about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/misc/openbangla-keyboard/default.nix
blob: c0a514367af973301933f8b2a9673590307be122 (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
{ lib
, stdenv
, fetchFromGitHub
, cargo
, cmake
, pkg-config
, rustPlatform
, rustc
, wrapQtAppsHook
, fcitx5
, ibus
, qtbase
, zstd
, withFcitx5Support ? false
, withIbusSupport ? false
}:

stdenv.mkDerivation rec {
  pname = "openbangla-keyboard";
  version = "unstable-2023-07-21";

  src = fetchFromGitHub {
    owner = "openbangla";
    repo = "openbangla-keyboard";
    # no upstream release in 3 years
    # fcitx5 support was added over a year after the last release
    rev = "780bd40eed16116222faff044bfeb61a07af158f";
    hash = "sha256-4CR4lgHB51UvS/RLc0AEfIKJ7dyTCOfDrQdGLf9de8E=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    cmake
    pkg-config
    cargo
    rustc
    rustPlatform.cargoSetupHook
    wrapQtAppsHook
  ];

  buildInputs = lib.optionals withFcitx5Support [
    fcitx5
  ] ++ lib.optionals withIbusSupport [
    ibus
  ] ++ [
    qtbase
    zstd
  ];

  cargoDeps = rustPlatform.fetchCargoTarball {
    inherit src;
    postPatch = ''
      cp ${./Cargo.lock} Cargo.lock
    '';
    sourceRoot = "${src.name}/${cargoRoot}";
    hash = "sha256-XMleyP2h1aBhtjXhuGHyU0BN+tuL12CGoj+kLY5uye0=";
  };

  cmakeFlags = lib.optionals withFcitx5Support [
    "-DENABLE_FCITX=YES"
  ] ++ lib.optionals withIbusSupport [
    "-DENABLE_IBUS=YES"
  ];

  cargoRoot = "src/engine/riti";
  postPatch = ''
    cp ${./Cargo.lock} ${cargoRoot}/Cargo.lock

    substituteInPlace CMakeLists.txt \
      --replace "/usr" "$out"

    substituteInPlace src/shared/FileSystem.cpp \
      --replace "/usr" "$out"
  '';

  meta = {
    isIbusEngine = withIbusSupport;
    description = "An OpenSource, Unicode compliant Bengali Input Method";
    homepage = "https://openbangla.github.io/";
    license = lib.licenses.gpl3Plus;
    maintainers = with lib.maintainers; [ eclairevoyant hqurve ];
    platforms = lib.platforms.linux;
    # never built on aarch64-linux since first introduction in nixpkgs
    broken = stdenv.isLinux && stdenv.isAarch64;
  };
}