2024-01-02 11:29:13 +00:00
{ stdenv
, lib
, fetchFromGitLab
, fetchpatch
, gitUpdater
2024-02-07 01:22:34 +00:00
, substituteAll
2024-01-02 11:29:13 +00:00
, 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
2024-02-07 01:22:34 +00:00
, validatePkgConfig
2024-01-02 11:29:13 +00:00
, wrapQtAppsHook
, xvfb-run
} :
let
listToQtVar = suffix : lib . makeSearchPathOutput " b i n " suffix ;
qtPluginPaths = listToQtVar qtbase . qtPluginPrefix [ qtbase qtpim qtsvg ] ;
qtQmlPaths = listToQtVar qtbase . qtQmlPrefix [ qtdeclarative qtfeedback qtgraphicaleffects ] ;
in
stdenv . mkDerivation ( finalAttrs : {
pname = " l o m i r i - u i - t o o l k i t " ;
2024-02-07 01:22:34 +00:00
version = " 1 . 3 . 5 0 1 2 " ;
2024-01-02 11:29:13 +00:00
src = fetchFromGitLab {
owner = " u b p o r t s " ;
repo = " d e v e l o p m e n t / c o r e / l o m i r i - u i - t o o l k i t " ;
rev = finalAttrs . version ;
2024-02-07 01:22:34 +00:00
hash = " s h a 2 5 6 - A z z 2 I O m / 7 X R v D b y I K a Y x r k R 4 7 e v S B 1 7 e j t s s u E J a y P c = " ;
2024-01-02 11:29:13 +00:00
} ;
outputs = [ " o u t " " d e v " ] ;
patches = [
# Upstreaming effort for these two patches: https://gitlab.com/ubports/development/core/lomiri-ui-toolkit/-/merge_requests/44
( fetchpatch {
name = " 0 0 0 1 - l o m i r i - u i - t o o l k i t - f i x - t e s t s - o n - q t - 5 . 1 5 . 4 . p a t c h " ;
url = " h t t p s : / / s a l s a . d e b i a n . o r g / u b p o r t s - t e a m / l o m i r i - u i - t o o l k i t / - / r a w / 1 a d 6 5 0 c 3 2 6 b a 9 7 0 6 d 5 4 9 d 1 d b e 8 3 3 5 c 7 0 f 6 b 3 8 2 c 8 / d e b i a n / p a t c h e s / 0 0 0 1 - f i x - t e s t s - o n - q t - 5 . 1 5 . 4 . p a t c h " ;
hash = " s h a 2 5 6 - Y 5 H V v u l R 2 7 6 0 D B z l m Y k I m b J / q I e q M I S q P p U p p b v 8 x J A = " ;
} )
( fetchpatch {
name = " 0 0 0 2 - l o m i r i - u i - t o o l k i t - f i x - t e s t s - o n - q t - 5 . 1 5 . 5 . p a t c h " ;
url = " h t t p s : / / s a l s a . d e b i a n . o r g / u b p o r t s - t e a m / l o m i r i - u i - t o o l k i t / - / r a w / 0 3 b c a f a d d 3 e 4 f d a 3 4 b c b 5 a f 2 3 4 5 4 f 4 b 2 0 2 c f 5 5 1 7 / d e b i a n / p a t c h e s / 0 0 0 2 - f i x - t e s t s - o n - q t - 5 . 1 5 . 5 . p a t c h " ;
hash = " s h a 2 5 6 - x 8 Z k 7 + V B S l M 1 6 a 3 V 1 y x J q I B 6 3 7 9 6 H 0 l s S + F 4 d v R / z 8 0 = " ;
} )
./2001-Mark-problematic-tests.patch
2024-02-07 01:22:34 +00:00
( substituteAll {
src = ./2002-Nixpkgs-versioned-QML-path.patch.in ;
name = " 2 0 0 2 - N i x p k g s - v e r s i o n e d - Q M L - p a t h . p a t c h " ;
qtVersion = lib . versions . major qtbase . version ;
} )
2024-01-02 11:29:13 +00:00
] ;
postPatch = ''
patchShebangs documentation/docs.sh tests /
substituteInPlace tests/tests.pro \
- - replace " \' ' $ \' ' $ P Y T H O N D I R " " $ d e v / ${ python3 . sitePackages } "
for subproject in po app-launch-profiler lomiri-ui-toolkit-launcher ; do
substituteInPlace $ subproject / $ subproject . pro \
- - replace " \' ' $ \' ' $ [ Q T _ I N S T A L L _ P R E F I X ] " " $ o u t " \
- - replace " \' ' $ \' ' $ [ Q T _ I N S T A L L _ L I B S ] " " $ o u t / l i b "
done
# Install apicheck tool into bin
substituteInPlace apicheck/apicheck.pro \
- - replace " \' ' $ \' ' $ [ Q T _ I N S T A L L _ L I B S ] / l o m i r i - u i - t o o l k i t " " $ o u t / b i n "
# 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 " / u s r " " / r u n / c u r r e n t - s y s t e m / s w "
# 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 ' _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 ' /usr/share ' ' $ { suru-icon-theme } /share '
'' ;
# With strictDeps, QMake only picks up Qt dependencies from nativeBuildInputs
strictDeps = false ;
nativeBuildInputs = [
perl
pkg-config
python3
qmake
2024-02-07 01:22:34 +00:00
validatePkgConfig
2024-01-02 11:29:13 +00:00
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
" C O N F I G + = n o _ d o c s "
# Ubuntu UITK compatibility, for older / not-yet-migrated applications
" C O N F I G + = u b u n t u - u i t k - c o m p a t "
" Q M A K E _ P K G C O N F I G _ P R E F I X = ${ placeholder " o u t " } "
] ;
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 ' 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 " ${ lib . getLib qtbase } / l i b " " \' ' ${ prefix } / l i b " \
- - replace " ${ lib . getDev qtbase } / i n c l u d e " " \' ' ${ prefix } / i n c l u d e "
done
# These are all dev-related tools, but declaring a bin output also moves around the QML modules
moveToOutput " b i n " " $ d e v "
'' ;
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 = " Q M L c o m p o n e n t s t o e a s e t h e c r e a t i o n o f b e a u t i f u l a p p l i c a t i o n s i n Q M L " ;
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 = " h t t p s : / / g i t l a b . c o m / u b p o r t s / d e v e l o p m e n t / c o r e / l o m i r i - u i - t o o l k i t " ;
2024-02-07 01:22:34 +00:00
changelog = " h t t p s : / / g i t l a b . c o m / u b p o r t s / d e v e l o p m e n t / c o r e / l o m i r i - u i - t o o l k i t / - / b l o b / ${ finalAttrs . version } / C h a n g e L o g " ;
2024-01-02 11:29:13 +00:00
license = with licenses ; [ gpl3Only cc-by-sa-30 ] ;
maintainers = teams . lomiri . members ;
platforms = platforms . linux ;
pkgConfigModules = [
" L o m i r i G e s t u r e s "
" L o m i r i M e t r i c s "
" L o m i r i T o o l k i t "
] ;
} ;
} )