base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / on / onboard / package.nix
blob0ebe02881003bfee4182bea1188f57f814a4e0b1
1 { fetchurl
2 , fetchpatch
3 , lib
4 , substituteAll
5 , aspellWithDicts
6 , at-spi2-core ? null
7 , atspiSupport ? true
8 , bash
9 , glib
10 , dconf
11 , gobject-introspection
12 , gsettings-desktop-schemas
13 , gtk3
14 , hunspell
15 , hunspellDicts
16 , hunspellWithDicts
17 , intltool
18 , isocodes
19 , libappindicator-gtk3
20 , libcanberra-gtk3
21 , mousetweaks
22 , udev
23 , libxkbcommon
24 , pkg-config
25 , procps
26 , python3
27 , wrapGAppsHook3
28 , xorg
29 , yelp
32 let
34   customHunspell = hunspellWithDicts [
35     hunspellDicts.en-us
36   ];
38   majorVersion = "1.4";
42 python3.pkgs.buildPythonApplication rec {
43   pname = "onboard";
44   version = "${majorVersion}.1";
46   src = fetchurl {
47     url = "https://launchpad.net/onboard/${majorVersion}/${version}/+download/${pname}-${version}.tar.gz";
48     sha256 = "0r9q38ikmr4in4dwqd8m9gh9xjbgxnfxglnjbfcapw8ybfnf3jh1";
49   };
51   patches = [
52     (substituteAll {
53       src = ./fix-paths.patch;
54       inherit mousetweaks;
55     })
56     # Allow loading hunspell dictionaries installed in NixOS system path
57     ./hunspell-use-xdg-datadirs.patch
59     # Python 3.12 fixes (otherwise crashes at startup)
60     (fetchpatch {
61       url = "https://github.com/void-linux/void-packages/raw/1be95325d320122efd5dedf7437839cfcca01f7a/srcpkgs/onboard/patches/python-3.12.patch";
62       hash = "sha256-Lw5wlaWFlP5rFlEWmlPo5Ux8idrmhET/X9yiu+2Akkk=";
63     })
64     (fetchpatch {
65       url = "https://github.com/void-linux/void-packages/raw/1be95325d320122efd5dedf7437839cfcca01f7a/srcpkgs/onboard/patches/thread-state.patch";
66       hash = "sha256-fJfxD7HshroiEVkaKVBGV7py8tdOhbcprcmBQNuxR9U=";
67     })
69     # Fix for https://bugs.launchpad.net/onboard/+bug/1948723
70     (fetchpatch {
71       url = "https://github.com/void-linux/void-packages/raw/9ef46bf26ac5acc1af5809f11c97b19c5e2233ed/srcpkgs/onboard/patches/fix-brokenformat.patch";
72       hash = "sha256-r9mvJNWpPR1gsayuSSLpzIuafEKqtADYklre0Ju+KOM=";
73     })
74   ];
76   nativeBuildInputs = [
77     gobject-introspection
78     intltool
79     pkg-config
80     wrapGAppsHook3
81   ];
83   buildInputs = [
84     bash
85     glib
86     dconf
87     gsettings-desktop-schemas
88     gtk3
89     hunspell
90     isocodes
91     libappindicator-gtk3
92     libcanberra-gtk3
93     libxkbcommon
94     mousetweaks
95     udev
96     xorg.libXtst
97     xorg.libxkbfile
98   ] ++ lib.optional atspiSupport at-spi2-core;
100   pythonPath = with python3.pkgs; [
101     dbus-python
102     distutils-extra
103     pyatspi
104     pycairo
105     pygobject3
106     systemd
107   ];
109   propagatedUserEnvPkgs = [
110     dconf
111   ];
113   nativeCheckInputs = [
114     # for Onboard.SpellChecker.aspell_cmd doctests
115     (aspellWithDicts (dicts: with dicts; [ en ]))
117     # for Onboard.SpellChecker.hunspell_cmd doctests
118     customHunspell
120     # for Onboard.SpellChecker.hunspell doctests
121     hunspellDicts.en-us
122     hunspellDicts.es-es
123     hunspellDicts.it-it
124   ];
126   # Tests have never been enabled, and upstream uses nose as a test
127   # runner (though not as a library).
128   doCheck = false;
130   preBuild = ''
131     # Unnecessary file, has been removed upstream
132     # https://github.com/NixOS/nixpkgs/pull/24986#issuecomment-296114062
133     rm -r Onboard/pypredict/attic
135     substituteInPlace  ./scripts/sokSettings.py \
136       --replace "#!/usr/bin/python3" "" \
137       --replace "PYTHON_EXECUTABLE," "\"$out/bin/onboard-settings\"" \
138       --replace '"-cfrom Onboard.settings import Settings\ns = Settings(False)"' ""
140     chmod -x ./scripts/sokSettings.py
142     patchShebangs .
144     substituteInPlace setup.py \
145       --replace "/etc" "$out/etc"
147     substituteInPlace  ./Onboard/LanguageSupport.py \
148       --replace "/usr/share/xml/iso-codes" "${isocodes}/share/xml/iso-codes"
150     substituteInPlace  ./Onboard/Indicator.py \
151       --replace   "/usr/bin/yelp" "${yelp}/bin/yelp"
153     substituteInPlace  ./gnome/Onboard_Indicator@onboard.org/extension.js \
154       --replace "/usr/bin/yelp" "${yelp}/bin/yelp"
156     substituteInPlace  ./Onboard/SpellChecker.py \
157       --replace "/usr/lib" "$out/lib"
159     substituteInPlace  ./data/org.onboard.Onboard.service  \
160       --replace "/usr/bin" "$out/bin"
162     substituteInPlace  ./Onboard/utils.py \
163       --replace "/usr/share" "$out/share"
164     substituteInPlace  ./onboard-defaults.conf.example \
165       --replace "/usr/share" "$out/share"
166     substituteInPlace  ./Onboard/Config.py \
167       --replace "/usr/share/onboard" "$out/share/onboard"
169     substituteInPlace  ./Onboard/WordSuggestions.py \
170       --replace "/usr/bin" "$out/bin"
172     # killall is dangerous on non-gnu platforms. Use pkill instead.
173     substituteInPlace  ./setup.py \
174       --replace '"killall",' '"${procps}/bin/pkill", "-x",'
175   '';
177   # setuptools to get distutils with python 3.12
178   installPhase = ''
179     ${(python3.withPackages (p: [ p.setuptools ])).interpreter} setup.py install --prefix="$out"
181     cp onboard-default-settings.gschema.override.example $out/share/glib-2.0/schemas/10_onboard-default-settings.gschema.override
182     glib-compile-schemas $out/share/glib-2.0/schemas/
183   '';
185   # Remove ubuntu icons.
186   postFixup = ''
187     rm -rf  $out/share/icons/ubuntu-mono-*
188   '';
190   meta = with lib; {
191     homepage = "https://launchpad.net/onboard";
192     description = "Onscreen keyboard useful for tablet PC users and for mobility impaired users";
193     maintainers = with maintainers; [ johnramsden ];
194     license = licenses.gpl3;
195   };