Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lomiri.lomiri-url-dispatcher: Split library into separate output #351228

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 83 additions & 70 deletions pkgs/desktops/lomiri/services/lomiri-url-dispatcher/default.nix
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
{ stdenv
, lib
, fetchFromGitLab
, fetchpatch
, gitUpdater
, testers
, cmake
, cmake-extras
, dbus
, dbus-test-runner
, glib
, gtest
, intltool
, json-glib
, libapparmor
, libxkbcommon
, lomiri-app-launch
, lomiri-ui-toolkit
, makeWrapper
, pkg-config
, python3
, qtbase
, qtdeclarative
, qtwayland
, runtimeShell
, sqlite
, systemd
, wrapQtAppsHook
{
stdenv,
lib,
fetchFromGitLab,
fetchpatch,
gitUpdater,
testers,
cmake,
cmake-extras,
dbus,
dbus-test-runner,
glib,
gtest,
intltool,
json-glib,
libapparmor,
libxkbcommon,
lomiri-app-launch,
lomiri-ui-toolkit,
makeWrapper,
pkg-config,
python3,
qtbase,
qtdeclarative,
qtwayland,
runtimeShell,
sqlite,
systemd,
wrapQtAppsHook,
}:

stdenv.mkDerivation (finalAttrs: {
Expand All @@ -42,6 +43,7 @@ stdenv.mkDerivation (finalAttrs: {
outputs = [
"out"
"dev"
"lib"
];

patches = [
Expand All @@ -51,21 +53,33 @@ stdenv.mkDerivation (finalAttrs: {
url = "https://gitlab.com/sunweaver/lomiri-url-dispatcher/-/commit/ebdd31b9640ca243e90bc7b8aca7951085998bd8.patch";
hash = "sha256-g4EohB3oDcWK4x62/3r/g6CFxqb7/rdK51+E/Fji1Do=";
})

# Make lomiri-url-dispatcher-gui wrappable
# Remove when https://gitlab.com/ubports/development/core/lomiri-url-dispatcher/-/merge_requests/28 merged & in release
(fetchpatch {
url = "https://gitlab.com/ubports/development/core/lomiri-url-dispatcher/-/commit/6512937e2b388ad1350072b8ed3b4140439b2321.patch";
hash = "sha256-P1A3hi8l7fJWFjGeK5hWYl8BoZMzRfo44MUTeM7vG2A=";
})
];

postPatch = ''
substituteInPlace data/CMakeLists.txt \
--replace "\''${SYSTEMD_USER_UNIT_DIR}" "\''${CMAKE_INSTALL_LIBDIR}/systemd/user"
postPatch =
''
substituteInPlace CMakeLists.txt \
--replace-fail 'pkg_get_variable(SYSTEMD_USER_UNIT_DIR systemd systemduserunitdir)' 'pkg_get_variable(SYSTEMD_USER_UNIT_DIR systemd systemduserunitdir DEFINE_VARIABLES prefix=''${CMAKE_INSTALL_PREFIX})' \

substituteInPlace tests/url_dispatcher_testability/CMakeLists.txt \
--replace "\''${PYTHON_PACKAGE_DIR}" "$out/${python3.sitePackages}"
substituteInPlace gui/lomiri-url-dispatcher-gui.desktop.in.in \
--replace-fail '@CMAKE_INSTALL_FULL_DATADIR@/lomiri-url-dispatcher/gui/lomiri-url-dispatcher-gui.svg' 'lomiri-url-dispatcher-gui'

# Update URI handler database whenever new url-handler is installed system-wide
substituteInPlace data/lomiri-url-dispatcher-update-system-dir.*.in \
--replace '@CMAKE_INSTALL_FULL_DATAROOTDIR@' '/run/current-system/sw/share'
'' + lib.optionalString finalAttrs.finalPackage.doCheck ''
patchShebangs tests/test-sql.sh
'';
substituteInPlace tests/url_dispatcher_testability/CMakeLists.txt \
--replace-fail "\''${PYTHON_PACKAGE_DIR}" "$out/${python3.sitePackages}"

# Update URI handler database whenever new url-handler is installed system-wide
substituteInPlace data/lomiri-url-dispatcher-update-system-dir.*.in \
--replace-fail '@CMAKE_INSTALL_FULL_DATAROOTDIR@' '/run/current-system/sw/share'
''
+ lib.optionalString finalAttrs.finalPackage.doCheck ''
patchShebangs tests/test-sql.sh
'';

strictDeps = true;

Expand All @@ -75,11 +89,16 @@ stdenv.mkDerivation (finalAttrs: {
intltool
makeWrapper
pkg-config
(python3.withPackages (ps: with ps; [
setuptools
] ++ lib.optionals finalAttrs.finalPackage.doCheck [
python-dbusmock
]))
(python3.withPackages (
ps:
with ps;
[
setuptools
]
++ lib.optionals finalAttrs.finalPackage.doCheck [
python-dbusmock
]
))
wrapQtAppsHook
];

Expand All @@ -104,8 +123,8 @@ stdenv.mkDerivation (finalAttrs: {
];

cmakeFlags = [
"-DLOCAL_INSTALL=ON"
"-Denable_mirclient=OFF"
(lib.cmakeBool "LOCAL_INSTALL" true)
(lib.cmakeBool "enable_mirclient" false)
];

doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
Expand All @@ -116,52 +135,46 @@ stdenv.mkDerivation (finalAttrs: {
dontWrapQtApps = true;

preFixup = ''
substituteInPlace $out/bin/lomiri-url-dispatcher-dump \
--replace '/bin/sh' '${runtimeShell}'
substituteInPlace $out/bin/lomiri-url-dispatcher-{dump,gui} \
--replace-fail '/bin/sh' '${runtimeShell}'

wrapProgram $out/bin/lomiri-url-dispatcher-dump \
--prefix PATH : ${lib.makeBinPath [ sqlite ]}

# Move from qmlscene call in desktop file to easier-to-wrap script
guiScript=$out/bin/lomiri-url-dispatcher-gui
guiExec=$(grep 'Exec=' $out/share/applications/lomiri-url-dispatcher-gui.desktop | cut -d'=' -f2-)

cat <<EOF >$guiScript
#!${runtimeShell}
$guiExec
EOF
chmod +x $guiScript

mkdir -p $out/share/icons/hicolor/scalable/apps
ln -s $out/share/lomiri-url-dispatcher/gui/lomiri-url-dispatcher-gui.svg $out/share/icons/hicolor/scalable/apps/

substituteInPlace $out/share/applications/lomiri-url-dispatcher-gui.desktop \
--replace "Exec=$guiExec" "Exec=$(basename $guiScript)" \
--replace "Icon=$out/share/lomiri-url-dispatcher/gui/lomiri-url-dispatcher-gui.svg" "Icon=lomiri-url-dispatcher-gui"

# Calls qmlscene from PATH, needs Qt plugins & QML components
qtWrapperArgs+=(
--prefix PATH : ${lib.makeBinPath [ qtdeclarative.dev ]}
)
wrapQtApp $guiScript
wrapQtApp $out/bin/lomiri-url-dispatcher-gui
'';

postFixup = ''
moveToOutput share $out
moveToOutput libexec $out
'';

passthru = {
tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
updateScript = gitUpdater { };
};

meta = with lib; {
meta = {
description = "Lomiri operating environment service for requesting URLs to be opened";
longDescription = ''
Allows applications to request a URL to be opened and handled by another
process without seeing the list of other applications on the system or
starting them inside its own Application Confinement.
Allows applications to request a URL to be opened and handled by another
process without seeing the list of other applications on the system or
starting them inside its own Application Confinement.
'';
homepage = "https://gitlab.com/ubports/development/core/lomiri-url-dispatcher";
license = with licenses; [ lgpl3Only gpl3Only ];
maintainers = teams.lomiri.members;
platforms = platforms.linux;
license = with lib.licenses; [
lgpl3Only
gpl3Only
];
maintainers = lib.teams.lomiri.members;
platforms = lib.platforms.linux;
pkgConfigModules = [
"lomiri-url-dispatcher"
];
Expand Down