summary refs log tree commit diff
path: root/pkgs/tools/inputmethods/ibus/default.nix
blob: 66d61b8c5e9df1bd7e4f948286291fe07d32a9a3 (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
{ stdenv, fetchurl, wrapGAppsHook
, intltool, isocodes, pkgconfig
, python3
, gtk2, gtk3, atk, dconf, glib, json_glib
, dbus, libnotify, gobjectIntrospection, wayland
}:

let
  emojiData = let
    srcs = {
      data = fetchurl {
        url = "http://unicode.org/Public/emoji/5.0/emoji-data.txt";
        sha256 = "0zfn3z61xy76yah3d24dd745qjssrib009m4nvqpnx4sf1r13i2x";
      };
      sequences = fetchurl {
        url = "http://unicode.org/Public/emoji/5.0/emoji-sequences.txt";
        sha256 = "0xzk7hi2a8macx9s5gj2pb36d38y8fa9001sj71g6kw25c2h94cn";
      };
      variation-sequences = fetchurl {
        url = "http://unicode.org/Public/emoji/5.0/emoji-variation-sequences.txt";
        sha256 = "1wlg4gbq7spmpppjfy5zdl82sj0hc836p8gljgfrjmwsjgybq286";
      };
      zwj-sequences = fetchurl {
        url = "http://unicode.org/Public/emoji/5.0/emoji-zwj-sequences.txt";
        sha256 = "0rrnk94mhm3k9vs74pvyvs4ir7f31f1libx7c196fmdqvp1qfafw";
      };
      test = fetchurl {
        url = "http://unicode.org/Public/emoji/5.0/emoji-test.txt";
        sha256 = "1dvxw5xp1xiy13c1p1c7l2xc9q8f8znk47kb7q8g7bbgbi21cq5m";
      };
    };
  in stdenv.mkDerivation {
    name = "emoji-data-5.0";
    unpackPhase = ":";
    dontBuild = true;
    installPhase = with stdenv.lib; ''
      mkdir $out
      ${builtins.toString (flip mapAttrsToList srcs (k: v: ''
        cp ${v} $out/emoji-${k}.txt
      ''))}
    '';
  };
  cldrEmojiAnnotation = stdenv.mkDerivation rec {
    name = "cldr-emoji-annotation-${version}";
    version = "31.0.1_1";
    src = fetchurl {
      url = "https://github.com/fujiwarat/cldr-emoji-annotation/releases/download/${version}/${name}.tar.gz";
      sha256 = "1a3qzsab7vzjqpdialp1g8ppr21x05v0ph8ngyq9pyjkx4vzcdi7";
    };
  };
  pyEnv = python3.buildEnv.override {
    extraLibs = [ python3.pkgs.pygobject3 ];
  };
in stdenv.mkDerivation rec {
  name = "ibus-${version}";
  version = "1.5.16";

  src = fetchurl {
    url = "https://github.com/ibus/ibus/releases/download/${version}/${name}.tar.gz";
    sha256 = "07py16jb81kd7vkqhcia9cb2avsbg5jswp2kzf0k4bprwkxppd9n";
  };

  postPatch = ''
    # These paths will be set in the wrapper.
    sed -e "/export IBUS_DATAROOTDIR/ s/^.*$//" \
        -e "/export IBUS_LIBEXECDIR/ s/^.*$//" \
        -e "/export IBUS_LOCALEDIR/ s/^.*$//" \
        -e "/export IBUS_PREFIX/ s/^.*$//" \
        -i "setup/ibus-setup.in"
  '';

  configureFlags = [
    "--disable-gconf"
    "--enable-dconf"
    "--disable-memconf"
    "--enable-ui"
    "--enable-python-library"
    "--with-unicode-emoji-dir=${emojiData}"
    "--with-emoji-annotation-dir=${cldrEmojiAnnotation}/share/unicode/cldr/common/annotations"
  ];

  buildInputs = [
    pyEnv
    intltool isocodes pkgconfig
    gtk2 gtk3 dconf
    json_glib
    dbus libnotify gobjectIntrospection wayland
  ];

  propagatedBuildInputs = [ glib ];

  nativeBuildInputs = [ wrapGAppsHook ];

  outputs = [ "out" "dev" ];

  enableParallelBuilding = true;

  preConfigure = ''
    # Fix hard-coded installation paths, so make does not try to overwrite our
    # Python installation.
    sed -e "/py2overridesdir=/ s|=.*$|=$out/lib/${python3.libPrefix}|" \
        -e "/pyoverridesdir=/ s|=.*$|=$out/lib/${python3.libPrefix}|" \
        -e "/PYTHON2_LIBDIR/ s|=.*|=$out/lib/${python3.libPrefix}|" \
        -i configure

    # Don't try to generate a system-wide dconf database; it wouldn't work.
    substituteInPlace data/dconf/Makefile.in --replace "dconf update" "echo"
  '';

  doInstallCheck = true;
  installCheckPhase = "$out/bin/ibus version";

  meta = with stdenv.lib; {
    homepage = https://github.com/ibus/ibus;
    description = "Intelligent Input Bus for Linux / Unix OS";
    platforms = platforms.linux;
    maintainers = [ maintainers.ttuegel ];
  };
}