From af1d2bd13a27e39eb306fe206ce0389c06c0e9b9 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Fri, 31 May 2024 22:11:59 +0200 Subject: [PATCH 1/4] lomiri.lomiri-app-launch: Inject /run/current-system/sw/bin into PATH LAL manages desktop file parsing for various parts of the Lomiri environment. It also handles turning them into SystemD services tracked in the background. And due to how things work one, it's code is also SystemD-launched by itself. When we package applications with desktop files, we don't want the Exec values to be absolute, so we patch out absolute paths. Without absolute paths, PATH is expected to have the path to the executables. But our PATHs don't always contain i.e. /run/current-system/sw/bin. Services launched by SystemD are one such instance. If LAL code is run under SystemD's restricted reduced PATH, then it fails to find the requested executables. This is what happens to content-hub, and it causes all transfer requests to be met with an immediate "could not launch peer"-like error, and a transfer being stuck halfway. To work around this (I wouldn't call this a real solution?), patch LAL code to: - also propagate whatever PATH it currently *does* have to its launched applications - postfix the PATH it has with /run/current-system/sw/bin, to give it a decent fallback These changes allow for lomiri-filemanager-app to be launched via a content-hub request from lomiri-system-settings (i.e. the background selection). --- .../2001-Inject-current-system-PATH.patch | 59 +++++++++++++++++++ .../development/lomiri-app-launch/default.nix | 3 + 2 files changed, 62 insertions(+) create mode 100644 pkgs/desktops/lomiri/development/lomiri-app-launch/2001-Inject-current-system-PATH.patch diff --git a/pkgs/desktops/lomiri/development/lomiri-app-launch/2001-Inject-current-system-PATH.patch b/pkgs/desktops/lomiri/development/lomiri-app-launch/2001-Inject-current-system-PATH.patch new file mode 100644 index 000000000000..86bf90085d7a --- /dev/null +++ b/pkgs/desktops/lomiri/development/lomiri-app-launch/2001-Inject-current-system-PATH.patch @@ -0,0 +1,59 @@ +From e4fe87427f24aa9b506c15c0f73f298e8909aabe Mon Sep 17 00:00:00 2001 +From: OPNA2608 +Date: Fri, 31 May 2024 21:31:46 +0200 +Subject: [PATCH] Inject current-system PATH + +--- + liblomiri-app-launch/jobs-systemd.cpp | 16 ++++++++++++++++ + liblomiri-app-launch/jobs-systemd.h | 1 + + 2 files changed, 17 insertions(+) + +diff --git a/liblomiri-app-launch/jobs-systemd.cpp b/liblomiri-app-launch/jobs-systemd.cpp +index e9be801..246bea8 100644 +--- a/liblomiri-app-launch/jobs-systemd.cpp ++++ b/liblomiri-app-launch/jobs-systemd.cpp +@@ -574,6 +574,20 @@ void SystemD::copyEnvByPrefix(const std::string& prefix, std::list>& env) ++{ ++ std::string newPath { "/run/current-system/sw/bin" }; ++ char* oldPath = getenv("PATH"); ++ if (oldPath != NULL && oldPath[0] != '\0') ++ { ++ newPath.insert(0, 1, ':'); ++ newPath.insert(0, oldPath); ++ } ++ setenv("PATH", newPath.c_str(), true); ++ copyEnv("PATH", env); ++} ++ + std::shared_ptr SystemD::launch( + const AppID& appId, + const std::string& job, +@@ -625,6 +639,8 @@ std::shared_ptr SystemD::launch( + + copyEnv("DISPLAY", env); + ++ setupNixosPath(env); ++ + for (const auto& prefix : {"DBUS_", "MIR_", "LOMIRI_APP_LAUNCH_"}) + { + copyEnvByPrefix(prefix, env); +diff --git a/liblomiri-app-launch/jobs-systemd.h b/liblomiri-app-launch/jobs-systemd.h +index fe35932..19bf44e 100644 +--- a/liblomiri-app-launch/jobs-systemd.h ++++ b/liblomiri-app-launch/jobs-systemd.h +@@ -136,6 +136,7 @@ private: + static void copyEnv(const std::string& envname, std::list>& env); + static void copyEnvByPrefix(const std::string& prefix, std::list>& env); + static int envSize(std::list>& env); ++ static void setupNixosPath(std::list>& env); + + static std::vector parseExec(std::list>& env); + static void application_start_cb(GObject* obj, GAsyncResult* res, gpointer user_data); +-- +2.42.0 + diff --git a/pkgs/desktops/lomiri/development/lomiri-app-launch/default.nix b/pkgs/desktops/lomiri/development/lomiri-app-launch/default.nix index 381a89fe10ff..f248ae9ca0d0 100644 --- a/pkgs/desktops/lomiri/development/lomiri-app-launch/default.nix +++ b/pkgs/desktops/lomiri/development/lomiri-app-launch/default.nix @@ -54,6 +54,9 @@ stdenv.mkDerivation (finalAttrs: { url = "https://gitlab.com/ubports/development/core/lomiri-app-launch/-/commit/0419b2592284f43ee5e76060948ea3d5f1c991fd.patch"; hash = "sha256-11pEhFi39Cvqb9Hg47kT8+5hq+bz6WmySqaIdwt1MVk="; }) + + # Use /run/current-system/sw/bin fallback for desktop file Exec= lookups, propagate to launched applications + ./2001-Inject-current-system-PATH.patch ]; postPatch = '' From 20c9038e157ddb5152a0693f75d46f158c805c05 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Fri, 31 May 2024 22:19:25 +0200 Subject: [PATCH 2/4] lomiri.lomiri-app-launch: Modernise abit - Patch has been merged, fetch merged one & update comment (hash is unchanged, checked) - We now have a CMake modern enough for pkg_get_variable DEFINE_VARIABLES, use it - substituteInPlace --replace is deprecated - with lib; in meta is frowned-upon --- .../development/lomiri-app-launch/default.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/desktops/lomiri/development/lomiri-app-launch/default.nix b/pkgs/desktops/lomiri/development/lomiri-app-launch/default.nix index f248ae9ca0d0..ea44e6babb64 100644 --- a/pkgs/desktops/lomiri/development/lomiri-app-launch/default.nix +++ b/pkgs/desktops/lomiri/development/lomiri-app-launch/default.nix @@ -48,10 +48,10 @@ stdenv.mkDerivation (finalAttrs: { }; patches = [ - # Remove when https://gitlab.com/ubports/development/core/lomiri-app-launch/-/merge_requests/57 merged & in release + # Remove when version > 0.1.9 (fetchpatch { name = "0001-lomiri-app-launch-Fix-typelib-gir-dependency.patch"; - url = "https://gitlab.com/ubports/development/core/lomiri-app-launch/-/commit/0419b2592284f43ee5e76060948ea3d5f1c991fd.patch"; + url = "https://gitlab.com/ubports/development/core/lomiri-app-launch/-/commit/8466e77914e73801499df224fcd4a53c4a0eab25.patch"; hash = "sha256-11pEhFi39Cvqb9Hg47kT8+5hq+bz6WmySqaIdwt1MVk="; }) @@ -64,10 +64,10 @@ stdenv.mkDerivation (finalAttrs: { # used pkg_get_variable, cannot replace prefix substituteInPlace data/CMakeLists.txt \ - --replace 'pkg_get_variable(SYSTEMD_USER_UNIT_DIR systemd systemduserunitdir)' 'set(SYSTEMD_USER_UNIT_DIR "''${CMAKE_INSTALL_PREFIX}/lib/systemd/user")' + --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/jobs-systemd.cpp \ - --replace '^(/usr)?' '^(/nix/store/\\w+-bash-.+)?' + --replace-fail '^(/usr)?' '^(/nix/store/\\w+-bash-.+)?' ''; strictDeps = true; @@ -139,13 +139,13 @@ stdenv.mkDerivation (finalAttrs: { updateScript = gitUpdater { }; }; - meta = with lib; { + meta = { description = "System and associated utilities to launch applications in a standard and confined way"; homepage = "https://gitlab.com/ubports/development/core/lomiri-app-launch"; changelog = "https://gitlab.com/ubports/development/core/lomiri-app-launch/-/blob/${finalAttrs.version}/ChangeLog"; - license = licenses.gpl3Only; - maintainers = teams.lomiri.members; - platforms = platforms.linux; + license = lib.licenses.gpl3Only; + maintainers = lib.teams.lomiri.members; + platforms = lib.platforms.linux; pkgConfigModules = [ "lomiri-app-launch-0" ]; From 0ddd3a49e916136451ccab8689d2dc9f718e35f5 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Fri, 31 May 2024 22:25:39 +0200 Subject: [PATCH 3/4] lomiri.content-hub: Fetch patch to fix data transfer We don't have a functional content-hub transfer test, so this slipped through the cracks during testing. (The background setting in LSS would be an easy one, but that calls an AccountsSetting function that doesn't exist outside of Ubuntu, so it wouldn't work anyway.) --- pkgs/desktops/lomiri/services/content-hub/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/desktops/lomiri/services/content-hub/default.nix b/pkgs/desktops/lomiri/services/content-hub/default.nix index 3df927d3ed2d..c57874d3ee77 100644 --- a/pkgs/desktops/lomiri/services/content-hub/default.nix +++ b/pkgs/desktops/lomiri/services/content-hub/default.nix @@ -80,6 +80,13 @@ stdenv.mkDerivation (finalAttrs: { url = "https://gitlab.com/ubports/development/core/content-hub/-/commit/6e30f4f10ef90e817ca01d32959b6c782de48955.patch"; hash = "sha256-TAbYn265RpHpulaRVaHy9XqNF+qoDE7YQIfFMPfqEhw="; }) + + # Remove when https://gitlab.com/ubports/development/core/lomiri-content-hub/-/merge_requests/40 merged & in release + (fetchpatch { + name = "0006-content-hub-Fix-AppArmor-less-transfer.patch"; + url = "https://gitlab.com/ubports/development/core/content-hub/-/commit/b58e5c8babf00ad7c402555c96254ce0165adb9e.patch"; + hash = "sha256-a7x/0NiUBmmFlq96jkHyLCL0f5NIFh5JR/H+FQ/2GqI="; + }) ]; postPatch = '' From 120fda2ef344872c39b57f703a033548806687f8 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Fri, 31 May 2024 22:33:49 +0200 Subject: [PATCH 4/4] lomiri.content-hub: Modernise abit - Some patches have been merged, fetch merged ones if possible & update comments - with lib; in meta is frowned-upon --- .../lomiri/services/content-hub/default.nix | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/pkgs/desktops/lomiri/services/content-hub/default.nix b/pkgs/desktops/lomiri/services/content-hub/default.nix index c57874d3ee77..a1fd99757844 100644 --- a/pkgs/desktops/lomiri/services/content-hub/default.nix +++ b/pkgs/desktops/lomiri/services/content-hub/default.nix @@ -47,11 +47,11 @@ stdenv.mkDerivation (finalAttrs: { ]; patches = [ - # Remove when https://gitlab.com/ubports/development/core/content-hub/-/merge_requests/33 merged & in release + # Remove when version > 1.1.1 (fetchpatch { name = "0001-content-hub-Migrate-to-GetConnectionCredentials.patch"; - url = "https://gitlab.com/ubports/development/core/content-hub/-/commit/9c0eae42d856b4b6e24fa609ade0e674c7a84cfe.patch"; - hash = "sha256-IWoCQKSCCk26n7133oG0Ht+iEjavn/IiOVUM+tCLX2U="; + url = "https://gitlab.com/ubports/development/core/content-hub/-/commit/9ec9df32f77383eec7994d8e3e6961531bc8464d.patch"; + hash = "sha256-14dZosMTMa1FDGEMuil0r1Hz6vn+L9XC83NMAqC7Ol8="; }) # Remove when https://gitlab.com/ubports/development/core/content-hub/-/merge_requests/34 merged & in release @@ -61,7 +61,7 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-T+6T9lXne6AhDFv9d7L8JNwdl8f0wjDmvSoNVPkHza4="; }) - # Remove when https://gitlab.com/ubports/development/core/content-hub/-/merge_requests/35 merged & in release + # Remove when version > 1.1.1 # fetchpatch2 due to renames, https://github.com/NixOS/nixpkgs/issues/32084 (fetchpatch2 { name = "0003-content-hub-Add-more-better-GNUInstallDirs-variables-usage.patch"; @@ -69,16 +69,11 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-kYN0eLwMyM/9yK+zboyEsoPKZMZ4SCXodVYsvkQr2F8="; }) - # Remove when https://gitlab.com/ubports/development/core/content-hub/-/merge_requests/37 merged & in release + # Remove when version > 1.1.1 (fetchpatch { - name = "0004-content-hub-Fix-generation-of-transfer_files.patch"; - url = "https://gitlab.com/ubports/development/core/content-hub/-/commit/7ab3a4421356f83515f0deffb5f97a5b38601c13.patch"; - hash = "sha256-MJZm3ny5t0/GX0bd5hGQbPM2k7M4KUvKqce/0cYYgvM="; - }) - (fetchpatch { - name = "0005-content-hub-Fix-generation-of-moc_test_harness.patch"; - url = "https://gitlab.com/ubports/development/core/content-hub/-/commit/6e30f4f10ef90e817ca01d32959b6c782de48955.patch"; - hash = "sha256-TAbYn265RpHpulaRVaHy9XqNF+qoDE7YQIfFMPfqEhw="; + name = "0004-content-hub-Fix-generation-of-transfer_files-and-moc_test_harness.patch"; + url = "https://gitlab.com/ubports/development/core/content-hub/-/commit/68899c75e77e1f34176b8a550d52794413e5070f.patch"; + hash = "sha256-HAxePnzY/cL2c+o+Aw2N1pdr8rsbHGmRsH2EQkrBcHg="; }) # Remove when https://gitlab.com/ubports/development/core/lomiri-content-hub/-/merge_requests/40 merged & in release @@ -182,7 +177,7 @@ stdenv.mkDerivation (finalAttrs: { updateScript = gitUpdater { }; }; - meta = with lib; { + meta = { description = "Content sharing/picking service"; longDescription = '' content-hub is a mediation service to let applications share content between them, @@ -190,10 +185,10 @@ stdenv.mkDerivation (finalAttrs: { ''; homepage = "https://gitlab.com/ubports/development/core/content-hub"; changelog = "https://gitlab.com/ubports/development/core/content-hub/-/blob/${finalAttrs.version}/ChangeLog"; - license = with licenses; [ gpl3Only lgpl3Only ]; + license = with lib.licenses; [ gpl3Only lgpl3Only ]; mainProgram = "content-hub-service"; - maintainers = teams.lomiri.members; - platforms = platforms.linux; + maintainers = lib.teams.lomiri.members; + platforms = lib.platforms.linux; pkgConfigModules = [ "libcontent-hub" "libcontent-hub-glib"