unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* D-Bus service files on foreign distributions
@ 2024-08-25 11:08 Roman Riabenko via
  2024-08-26  8:27 ` Nils Landt
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Riabenko via @ 2024-08-25 11:08 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

Hello

How to expose service files to D-Bus on a foreign distribution?

I installed gnome-text-editor with guix on a foreign distribution
(PureOS byzantium). It would run from command line, but fail to start
from the applications grid with the following error.

$ journalctl -f
сер 25 10:35:03 pureos phosh[1402]: Failed to launch app 'Текстовий
редактор' with startup id: '6546b399-a2e0-4ded-b278-84863a9f32bf'

I considered the presence of "DBusActivatable=true" in its desktop file
and copied the service file. That allowed me to launch the application
from the icon as expected. 

$ sudo cp /home/purism/.guix-profile/share/dbus-
1/services/org.gnome.TextEditor.service /usr/share/dbus-1/services/

Is there a better approach for making the service files available to D-
Bus on a foreign distribution?

Roman

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: D-Bus service files on foreign distributions
  2024-08-25 11:08 D-Bus service files on foreign distributions Roman Riabenko via
@ 2024-08-26  8:27 ` Nils Landt
  2024-09-11 18:57   ` Roman Riabenko via
  0 siblings, 1 reply; 5+ messages in thread
From: Nils Landt @ 2024-08-26  8:27 UTC (permalink / raw)
  To: Roman Riabenko, Roman Riabenko via

> Roman Riabenko via <help-guix@gnu.org> hat am 25.08.2024 13:08 CEST geschrieben:
> 
>  
> Hello
> 
> How to expose service files to D-Bus on a foreign distribution?
> 
> I installed gnome-text-editor with guix on a foreign distribution
> (PureOS byzantium). It would run from command line, but fail to start
> from the applications grid with the following error.
> 
> $ journalctl -f
> сер 25 10:35:03 pureos phosh[1402]: Failed to launch app 'Текстовий
> редактор' with startup id: '6546b399-a2e0-4ded-b278-84863a9f32bf'
> 
> I considered the presence of "DBusActivatable=true" in its desktop file
> and copied the service file. That allowed me to launch the application
> from the icon as expected. 
> 
> $ sudo cp /home/purism/.guix-profile/share/dbus-
> 1/services/org.gnome.TextEditor.service /usr/share/dbus-1/services/
> 
> Is there a better approach for making the service files available to D-
> Bus on a foreign distribution?

I'm 100% guessing here, but I think systemd just doesn't see your service files because they are not in the search path.
If this is the case, you can set XDG_DATA_DIRS in ~/.config/systemd/user.conf (under the Manager header), i.e.:
[Manager]
ManagerEnvironment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"

If that doesn't work, I'm out of ideas :)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: D-Bus service files on foreign distributions
  2024-08-26  8:27 ` Nils Landt
@ 2024-09-11 18:57   ` Roman Riabenko via
  2024-09-12 11:13     ` Nils Landt
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Riabenko via @ 2024-09-11 18:57 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 2852 bytes --]

У пн, 2024-08-26 у 10:27 +0200, Nils Landt пише:
> > Roman Riabenko via <help-guix@gnu.org> hat am 25.08.2024 13:08 CEST
> > geschrieben:
> > 
> > How to expose service files to D-Bus on a foreign distribution?
> 
> I'm 100% guessing here, but I think systemd just doesn't see your
> service files because they are not in the search path.
> If this is the case, you can set XDG_DATA_DIRS in
> ~/.config/systemd/user.conf (under the Manager header), i.e.:
> [Manager]
> ManagerEnvironment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"

Thank you for the suggestion. The lines are already present. I assume
that the guix installation script added them.

$ cat ~/.config/systemd/user.conf
[Manager]
ManagerEnvironment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"

It may be working because the systemd environment for the user session
gets the value.

$ systemctl --user show-environment | grep XDG_DATA_DIRS
XDG_DATA_DIRS=/home/purism/.guix-profile/share:/home/purism/.guix-
profile/share:/usr/share/librem5:/home/purism/.guix-
profile/share:/home/purism/.guix-
profile/share:/usr/share/librem5:/home/purism/.local/share/flatpak/expo
rts/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/

But systemd does not pass the value to the user DBus environment.

$ systemctl --user status dbus | grep PID
   Main PID: 1261 (dbus-daemon)
$ sudo strings /proc/1261/environ | grep XDG_DATA_DIRS
XDG_DATA_DIRS=/home/purism/.local/share/flatpak/exports/share:/var/lib/
flatpak/exports/share:/usr/local/share/:/usr/share/

So, DBus does not see the service files in the guix profile.

$ LC_ALL=C gdbus call --session --method
org.freedesktop.DBus.Introspectable.Introspect --dest
org.gnome.TextEditor --object-path=/org/gnome/TextEditor
Error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name
org.gnome.TextEditor was not provided by any .service files

The manual page for systemd-system.conf says that to set manager
environment variables passed to all executed process, one can set
DefaultEnvironment option. I set it as suggested in
https://unix.stackexchange.com/a/698459/423679

$ cat ~/.config/systemd/user.conf
[Manager]
ManagerEnvironment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"
DefaultEnvironment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"

This change was ignored. So, I tried adding it to the file specified in
the manual page.

$ cat /etc/systemd/user.conf | grep DefaultEnvironment
DefaultEnvironment="XDG_DATA_DIRS=%h/.guix-profile/share"

But I could not login with that. I do not know how to investigate it
further. Any suggestions are appreciated. However, it appears that the
problem comes entirely from how DBus environment was configured in the
host distribution. So, I will proceed looking for help there.

Roman


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: D-Bus service files on foreign distributions
  2024-09-11 18:57   ` Roman Riabenko via
@ 2024-09-12 11:13     ` Nils Landt
  2024-09-12 19:54       ` Roman Riabenko via
  0 siblings, 1 reply; 5+ messages in thread
From: Nils Landt @ 2024-09-12 11:13 UTC (permalink / raw)
  To: Roman Riabenko, Roman Riabenko via


> Roman Riabenko via <help-guix@gnu.org> hat am 11.09.2024 20:57 CEST geschrieben:
> 
>  
> У пн, 2024-08-26 у 10:27 +0200, Nils Landt пише:
> > > Roman Riabenko via <help-guix@gnu.org> hat am 25.08.2024 13:08 CEST
> > > geschrieben:
> > > 
> > > How to expose service files to D-Bus on a foreign distribution?
> > 
> > I'm 100% guessing here, but I think systemd just doesn't see your
> > service files because they are not in the search path.
> > If this is the case, you can set XDG_DATA_DIRS in
> > ~/.config/systemd/user.conf (under the Manager header), i.e.:
> > [Manager]
> > ManagerEnvironment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"
> 
> Thank you for the suggestion. The lines are already present. I assume
> that the guix installation script added them.

From what I can tell, the installation script does not do this. Maybe you did it in the past already? Anyway, shouldn't matter.

> $ cat ~/.config/systemd/user.conf
> [Manager]
> ManagerEnvironment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"
> 
> It may be working because the systemd environment for the user session
> gets the value.
> 
> $ systemctl --user show-environment | grep XDG_DATA_DIRS
> XDG_DATA_DIRS=/home/purism/.guix-profile/share:/home/purism/.guix-
> profile/share:/usr/share/librem5:/home/purism/.guix-
> profile/share:/home/purism/.guix-
> profile/share:/usr/share/librem5:/home/purism/.local/share/flatpak/expo
> rts/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/
> 
> But systemd does not pass the value to the user DBus environment.
> 
> $ systemctl --user status dbus | grep PID
>    Main PID: 1261 (dbus-daemon)
> $ sudo strings /proc/1261/environ | grep XDG_DATA_DIRS
> XDG_DATA_DIRS=/home/purism/.local/share/flatpak/exports/share:/var/lib/
> flatpak/exports/share:/usr/local/share/:/usr/share/
> 
> So, DBus does not see the service files in the guix profile.
> 
> $ LC_ALL=C gdbus call --session --method
> org.freedesktop.DBus.Introspectable.Introspect --dest
> org.gnome.TextEditor --object-path=/org/gnome/TextEditor
> Error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name
> org.gnome.TextEditor was not provided by any .service files
> 
> The manual page for systemd-system.conf says that to set manager
> environment variables passed to all executed process, one can set
> DefaultEnvironment option. I set it as suggested in
> https://unix.stackexchange.com/a/698459/423679
> 
> $ cat ~/.config/systemd/user.conf
> [Manager]
> ManagerEnvironment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"
> DefaultEnvironment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"
> 
> This change was ignored. So, I tried adding it to the file specified in
> the manual page.

DefaultEnvironment does nothing here. Processes spawned by the user manager inherit the environment variables from the user manager.

> $ cat /etc/systemd/user.conf | grep DefaultEnvironment
> DefaultEnvironment="XDG_DATA_DIRS=%h/.guix-profile/share"

Looking at the purism docs (https://software.pureos.net/package/src/pureos/byzantium/systemd), systemd is version 247. But %h expansion in user config is only available since systemd 256.1 (https://github.com/systemd/systemd/pull/26675).
So maybe you can try explicitly specifying the path here.
I don't think it will help, but it's something :)

BUT! While I was writing this, I noticed that ManagerEnvironment itself was added in version 248! So if you're really on 247, it can't work.

In this case, I suggest you try a drop-in file for the dbus, e.g.:
systemctl --user edit dbus
(add the following two lines as only uncommented ones):
[Service]
Environment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: D-Bus service files on foreign distributions
  2024-09-12 11:13     ` Nils Landt
@ 2024-09-12 19:54       ` Roman Riabenko via
  0 siblings, 0 replies; 5+ messages in thread
From: Roman Riabenko via @ 2024-09-12 19:54 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 2175 bytes --]

У чт, 2024-09-12 у 13:13 +0200, Nils Landt пише:
> 
> > Roman Riabenko via <help-guix@gnu.org> hat am 11.09.2024 20:57 CEST
> > geschrieben:
> > 
> > У пн, 2024-08-26 у 10:27 +0200, Nils Landt пише:
> > > > Roman Riabenko via <help-guix@gnu.org> hat am 25.08.2024 13:08
> > > > CEST
> > > > geschrieben:
> > > > 
> > > > How to expose service files to D-Bus on a foreign distribution?
> 
> DefaultEnvironment does nothing here. Processes spawned by the user
> manager inherit the environment variables from the user manager.
> 
> > $ cat /etc/systemd/user.conf | grep DefaultEnvironment
> > DefaultEnvironment="XDG_DATA_DIRS=%h/.guix-profile/share"
> 
> Looking at the purism docs (
> https://software.pureos.net/package/src/pureos/byzantium/systemd),
> systemd is version 247. But %h expansion in user config is only
> available since systemd 256.1 (
> https://github.com/systemd/systemd/pull/26675).
> So maybe you can try explicitly specifying the path here.
> I don't think it will help, but it's something :)

I tried specifying the full path for DefaultEnvironment in
/etc/systemd/user.conf but was unable to login with it too. Setting
ManagerEnvironment there was ignored.

$ systemd --version
/etc/systemd/user.conf:31: Unknown key name 'ManagerEnvironment' in
section 'Manager', ignoring.
systemd 247 (247.3-7+deb11u6)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP
+LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID
+ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=unified

> BUT! While I was writing this, I noticed that ManagerEnvironment
> itself was added in version 248! So if you're really on 247, it can't
> work.

You are right!

The local manual page for systemd-system.conf does not have the
ManagerEnvironment option either.

> In this case, I suggest you try a drop-in file for the dbus, e.g.:
> systemctl --user edit dbus
> (add the following two lines as only uncommented ones):
> [Service]
> Environment="XDG_DATA_DIRS=/home/purism/.guix-profile/share"

Thank you! Now I can launch all applications from the icons grid as
expected so far.

Roman

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-12 19:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-25 11:08 D-Bus service files on foreign distributions Roman Riabenko via
2024-08-26  8:27 ` Nils Landt
2024-09-11 18:57   ` Roman Riabenko via
2024-09-12 11:13     ` Nils Landt
2024-09-12 19:54       ` Roman Riabenko via

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).