summary refs log tree commit diff
path: root/pkgs/applications/misc/onboard/default.nix
blob: d52120e0fb7d08111659a71ac9c4641d8af51f7f (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
{ fetchurl
, lib
, substituteAll
, aspellWithDicts
, at-spi2-core ? null
, atspiSupport ? true
, bash
, glib
, glibcLocales
, dconf
, gobject-introspection
, gsettings-desktop-schemas
, gtk3
, hunspell
, hunspellDicts
, hunspellWithDicts
, intltool
, isocodes
, libcanberra-gtk3
, mousetweaks
, udev
, libxkbcommon
, pkg-config
, procps
, python3
, wrapGAppsHook
, xorg
, yelp
}:

let

  customHunspell = hunspellWithDicts [
    hunspellDicts.en-us
  ];

  majorVersion = "1.4";

in

python3.pkgs.buildPythonApplication rec {
  pname = "onboard";
  version = "${majorVersion}.1";

  src = fetchurl {
    url = "https://launchpad.net/onboard/${majorVersion}/${version}/+download/${pname}-${version}.tar.gz";
    sha256 = "0r9q38ikmr4in4dwqd8m9gh9xjbgxnfxglnjbfcapw8ybfnf3jh1";
  };

  patches = [
    (substituteAll {
      src = ./fix-paths.patch;
      inherit mousetweaks;
    })
    # Allow loading hunspell dictionaries installed in NixOS system path
    ./hunspell-use-xdg-datadirs.patch
  ];

  nativeBuildInputs = [
    gobject-introspection
    intltool
    pkg-config
    wrapGAppsHook
  ];

  buildInputs = [
    bash
    glib
    dconf
    gsettings-desktop-schemas
    gtk3
    hunspell
    isocodes
    libcanberra-gtk3
    libxkbcommon
    mousetweaks
    udev
    xorg.libXtst
    xorg.libxkbfile
  ] ++ lib.optional atspiSupport at-spi2-core;

  propagatedBuildInputs = with python3.pkgs; [
    dbus-python
    distutils_extra
    pyatspi
    pycairo
    pygobject3
    systemd
  ];

  propagatedUserEnvPkgs = [
    dconf
  ];

  checkInputs = [
    # for Onboard.SpellChecker.aspell_cmd doctests
    (aspellWithDicts (dicts: with dicts; [ en ]))

    # for Onboard.SpellChecker.hunspell_cmd doctests
    customHunspell

    # for Onboard.SpellChecker.hunspell doctests
    hunspellDicts.en-us
    hunspellDicts.es-es
    hunspellDicts.it-it

    python3.pkgs.nose
  ];

  # Temporary fix, see https://github.com/NixOS/nixpkgs/issues/56943
  strictDeps = false;

  doCheck = false;

  preBuild = ''
    # Unnecessary file, has been removed upstream
    # https://github.com/NixOS/nixpkgs/pull/24986#issuecomment-296114062
    rm -r Onboard/pypredict/attic

    substituteInPlace  ./scripts/sokSettings.py \
      --replace "#!/usr/bin/python3" "" \
      --replace "PYTHON_EXECUTABLE," "\"$out/bin/onboard-settings\"" \
      --replace '"-cfrom Onboard.settings import Settings\ns = Settings(False)"' ""

    chmod -x ./scripts/sokSettings.py

    patchShebangs .

    substituteInPlace setup.py \
      --replace "/etc" "$out/etc"

    substituteInPlace  ./Onboard/LanguageSupport.py \
      --replace "/usr/share/xml/iso-codes" "${isocodes}/share/xml/iso-codes" \
      --replace "/usr/bin/yelp" "${yelp}/bin/yelp"

    substituteInPlace  ./Onboard/Indicator.py \
      --replace   "/usr/bin/yelp" "${yelp}/bin/yelp"

    substituteInPlace  ./gnome/Onboard_Indicator@onboard.org/extension.js \
      --replace "/usr/bin/yelp" "${yelp}/bin/yelp"

    substituteInPlace  ./Onboard/SpellChecker.py \
      --replace "/usr/lib" "$out/lib"

    substituteInPlace  ./data/org.onboard.Onboard.service  \
      --replace "/usr/bin" "$out/bin"

    substituteInPlace  ./Onboard/utils.py \
      --replace "/usr/share" "$out/share"
    substituteInPlace  ./onboard-defaults.conf.example \
      --replace "/usr/share" "$out/share"
    substituteInPlace  ./Onboard/Config.py \
      --replace "/usr/share/onboard" "$out/share/onboard"

    substituteInPlace  ./Onboard/WordSuggestions.py \
      --replace "/usr/bin" "$out/bin"

    # killall is dangerous on non-gnu platforms. Use pkill instead.
    substituteInPlace  ./setup.py \
      --replace '"killall",' '"${procps}/bin/pkill", "-x",'
  '';

  installPhase = ''
    ${python3.interpreter} setup.py install --prefix="$out"

    cp onboard-default-settings.gschema.override.example $out/share/glib-2.0/schemas/10_onboard-default-settings.gschema.override
    glib-compile-schemas $out/share/glib-2.0/schemas/
  '';

  # Remove ubuntu icons.
  postFixup = ''
    rm -rf  $out/share/icons/ubuntu-mono-*
  '';

  meta = with lib; {
    homepage = "https://launchpad.net/onboard";
    description = "Onscreen keyboard useful for tablet PC users and for mobility impaired users";
    maintainers = with maintainers; [ johnramsden ];
    license = licenses.gpl3;
  };
}