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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
{ stdenv
, lib
, fetchFromGitLab
, gitUpdater
, substituteAll
, testers
, dbus-test-runner
, dpkg
, gdb
, glib
, lttng-ust
, perl
, pkg-config
, python3
, qmake
, qtbase
, qtdeclarative
, qtfeedback
, qtgraphicaleffects
, qtpim
, qtquickcontrols2
, qtsvg
, qtsystems
, suru-icon-theme
, validatePkgConfig
, wrapQtAppsHook
, xvfb-run
}:
let
listToQtVar = suffix: lib.makeSearchPathOutput "bin" suffix;
qtPluginPaths = listToQtVar qtbase.qtPluginPrefix [ qtbase qtpim qtsvg ];
qtQmlPaths = listToQtVar qtbase.qtQmlPrefix [ qtdeclarative qtfeedback qtgraphicaleffects ];
in
stdenv.mkDerivation (finalAttrs: {
pname = "lomiri-ui-toolkit";
version = "1.3.5100";
src = fetchFromGitLab {
owner = "ubports";
repo = "development/core/lomiri-ui-toolkit";
rev = finalAttrs.version;
hash = "sha256-r+wUCl+ywFcgFYo7BjBoXiulQptd1Zd3LJchXiMtx4I=";
};
outputs = [ "out" "dev" ];
patches = [
./2001-Mark-problematic-tests.patch
(substituteAll {
src = ./2002-Nixpkgs-versioned-QML-path.patch.in;
name = "2002-Nixpkgs-versioned-QML-path.patch";
qtVersion = lib.versions.major qtbase.version;
})
];
postPatch = ''
patchShebangs documentation/docs.sh tests/
for subproject in po app-launch-profiler lomiri-ui-toolkit-launcher; do
substituteInPlace $subproject/$subproject.pro \
--replace-fail "\''$\''$[QT_INSTALL_PREFIX]" "$out" \
--replace-warn "\''$\''$[QT_INSTALL_LIBS]" "$out/lib"
done
# Install apicheck tool into bin
substituteInPlace apicheck/apicheck.pro \
--replace-fail "\''$\''$[QT_INSTALL_LIBS]/lomiri-ui-toolkit" "$out/bin"
# Causes redefinition error with our own fortify hardening
sed -i '/DEFINES += _FORTIFY_SOURCE/d' features/lomiri_common.prf
# Reverse dependencies (and their reverse dependencies too) access the function patched here to register their gettext catalogues,
# so hardcoding any prefix here will make only catalogues in that prefix work. APP_DIR envvar will override this, but with domains from multiple derivations being
# used in a single application (lomiri-system-settings), that's of not much use either.
# https://gitlab.com/ubports/development/core/lomiri-ui-toolkit/-/blob/dcb3a523c56a400e5c3c163c2836cafca168767e/src/LomiriToolkit/i18n.cpp#L101-129
#
# This could be solved with a reference to the prefix of whoever requests the domain, but the call happens via some automatic Qt / QML callback magic,
# I'm not sure what the best way of injecting that there would be.
# https://gitlab.com/ubports/development/core/lomiri-ui-toolkit/-/blob/dcb3a523c56a400e5c3c163c2836cafca168767e/src/LomiriToolkit/i18n_p.h#L34
#
# Using /run/current-system/sw/share/locale instead of /usr/share/locale isn't a great
# solution, but at least it should get us working localisations
substituteInPlace src/LomiriToolkit/i18n.cpp \
--replace-fail "/usr" "/run/current-system/sw"
# The code here overrides the regular QML import variables so the just-built modules are found & used in the tests
# But we need their QML dependencies too, so put them back in there
substituteInPlace export_qml_dir.sh \
--replace-fail '_IMPORT_PATH=$BUILD_DIR/qml' '_IMPORT_PATH=$BUILD_DIR/qml:${qtQmlPaths}'
# These tests try to load Suru theme icons, but override XDG_DATA_DIRS / use full paths to load them
substituteInPlace \
tests/unit/visual/tst_visual.cpp \
tests/unit/visual/tst_icon.{11,13}.qml \
tests/unit/visual/tst_imageprovider.11.qml \
--replace-fail '/usr/share' '${suru-icon-theme}/share'
'';
# With strictDeps, QMake only picks up Qt dependencies from nativeBuildInputs
strictDeps = false;
nativeBuildInputs = [
perl
pkg-config
python3
qmake
validatePkgConfig
wrapQtAppsHook
];
buildInputs = [
glib
lttng-ust
qtbase
qtdeclarative
qtpim
qtquickcontrols2
qtsystems
];
propagatedBuildInputs = [
qtfeedback
qtgraphicaleffects
qtsvg
];
nativeCheckInputs = [
dbus-test-runner
dpkg # `dpkg-architecture -qDEB_HOST_ARCH` response decides how tests are run
gdb
xvfb-run
];
qmakeFlags = [
# docs require Qt5's qdoc, which we don't have before https://github.com/NixOS/nixpkgs/pull/245379
"CONFIG+=no_docs"
# Ubuntu UITK compatibility, for older / not-yet-migrated applications
"CONFIG+=ubuntu-uitk-compat"
"QMAKE_PKGCONFIG_PREFIX=${placeholder "out"}"
];
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
# Explicitly not parallel-safe, large parts are always run in series and at least qquick_image_extension fails with parallelism
enableParallelChecking = false;
checkPhase = ''
runHook preCheck
export HOME=$PWD
# XDG_RUNTIME_DIR with wrong permissions causes warnings that are interpreted as errors in the test suite
export XDG_RUNTIME_DIR=$PWD/runtime-dir
mkdir -p $XDG_RUNTIME_DIR
chmod -R 700 $XDG_RUNTIME_DIR
# Tests need some Qt plugins
# Many tests try to load Suru theme icons via XDG_DATA_DIRS
export QT_PLUGIN_PATH=${qtPluginPaths}
export XDG_DATA_DIRS=${suru-icon-theme}/share
tests/xvfb.sh make check ''${enableParallelChecking:+-j''${NIX_BUILD_CORES}}
runHook postCheck
'';
preInstall = ''
# wrapper script calls qmlplugindump, crashes due to lack of minimal platform plugin
# Could not find the Qt platform plugin "minimal" in ""
# Available platform plugins are: wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx.
export QT_PLUGIN_PATH=${qtPluginPaths}
# Qt-generated wrapper script lacks QML paths to dependencies
for qmlModule in Components PerformanceMetrics Test; do
substituteInPlace src/imports/$qmlModule/wrapper.sh \
--replace-fail 'QML2_IMPORT_PATH=' 'QML2_IMPORT_PATH=${qtQmlPaths}:'
done
'';
postInstall = ''
# Code loads Qt's qt_module.prf, which force-overrides all QMAKE_PKGCONFIG_* variables except PREFIX for QMake-generated pkg-config files
for pcFile in Lomiri{Gestures,Metrics,Toolkit}.pc; do
substituteInPlace $out/lib/pkgconfig/$pcFile \
--replace-fail "${lib.getLib qtbase}/lib" "\''${prefix}/lib" \
--replace-fail "${lib.getDev qtbase}/include" "\''${prefix}/include"
done
# These are all dev-related tools, but declaring a bin output also moves around the QML modules
moveToOutput "bin" "$dev"
'';
postFixup = ''
for qtBin in $dev/bin/{apicheck,lomiri-ui-toolkit-launcher}; do
wrapQtApp $qtBin
done
'';
passthru = {
tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
updateScript = gitUpdater { };
};
meta = with lib; {
description = "QML components to ease the creation of beautiful applications in QML";
longDescription = ''
This project consists of a set of QML components to ease the creation of beautiful applications in QML for Lomiri.
QML alone lacks built-in components for basic widgets like Button, Slider, Scrollbar, etc, meaning a developer has
to build them from scratch.
This toolkit aims to stop this duplication of work, supplying beautiful components ready-made and with a clear and
consistent API.
These components are fully themeable so the look and feel can be easily customized. Resolution independence
technology is built in so UIs are scaled to best suit the display.
Other features:
- localisation through gettext
'';
homepage = "https://gitlab.com/ubports/development/core/lomiri-ui-toolkit";
changelog = "https://gitlab.com/ubports/development/core/lomiri-ui-toolkit/-/blob/${finalAttrs.version}/ChangeLog";
license = with licenses; [ gpl3Only cc-by-sa-30 ];
maintainers = teams.lomiri.members;
platforms = platforms.linux;
pkgConfigModules = [
"LomiriGestures"
"LomiriMetrics"
"LomiriToolkit"
];
};
})
|