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-app-launch,content-hub}: Fix issues with peer spawning & data transfer #316255

Merged
merged 4 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From e4fe87427f24aa9b506c15c0f73f298e8909aabe Mon Sep 17 00:00:00 2001
From: OPNA2608 <[email protected]>
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<std::pair<std
}
}

+/* We don't have a normal PATH, so we need to inject our special one as a fallback & propagate it */
+void SystemD::setupNixosPath(std::list<std::pair<std::string, std::string>>& 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<Application::Instance> SystemD::launch(
const AppID& appId,
const std::string& job,
@@ -625,6 +639,8 @@ std::shared_ptr<Application::Instance> 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<std::pair<std::string, std::string>>& env);
static void copyEnvByPrefix(const std::string& prefix, std::list<std::pair<std::string, std::string>>& env);
static int envSize(std::list<std::pair<std::string, std::string>>& env);
+ static void setupNixosPath(std::list<std::pair<std::string, std::string>>& env);

static std::vector<std::string> parseExec(std::list<std::pair<std::string, std::string>>& env);
static void application_start_cb(GObject* obj, GAsyncResult* res, gpointer user_data);
--
2.42.0

19 changes: 11 additions & 8 deletions pkgs/desktops/lomiri/development/lomiri-app-launch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,26 @@ 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=";
})

# Use /run/current-system/sw/bin fallback for desktop file Exec= lookups, propagate to launched applications
./2001-Inject-current-system-PATH.patch
];

postPatch = ''
patchShebangs tests/{desktop-hook-test.sh.in,repeat-until-pass.sh}

# 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;
Expand Down Expand Up @@ -136,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"
];
Expand Down
32 changes: 17 additions & 15 deletions pkgs/desktops/lomiri/services/content-hub/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -61,24 +61,26 @@ 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";
url = "https://gitlab.com/ubports/development/core/content-hub/-/commit/3c5ca4a8ec125e003aca78c14521b70140856c25.patch";
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=";
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
(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 = "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=";
})
];

Expand Down Expand Up @@ -175,18 +177,18 @@ 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,
even if they are not running at the same time.
'';
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"
Expand Down