diff mbox series

[bug#70282,1/2] gnu: gnome-shell: Wrap d-bus services.

Message ID fbadd59837f7c90c8040a8abc91e7da7b09b712a.1712590252.git.dariqq@posteo.net
State New
Headers show
Series Fix gnome-shell screenrecorder | expand

Commit Message

Dariqq April 8, 2024, 3:53 p.m. UTC
Some of the dbus services can't find typelibs.

* gnu/packages/patches/gnome-shell-wrappable-dbus-services.patch: New file
* gnu/lokal.mk: Register it.
* gnu/packages/gnome.scm (gnome-shell)[arguments]<#:phases>{'wrap}: Also wrap dbus-services.

Change-Id: I2c31bf1bd92e281b86c57b06988c6a3793a58d40
---
 gnu/local.mk                                  |  1 +
 gnu/packages/gnome.scm                        | 13 +++-
 .../gnome-shell-wrappable-dbus-services.patch | 59 +++++++++++++++++++
 3 files changed, 71 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/gnome-shell-wrappable-dbus-services.patch

Comments

Liliana Marie Prikler April 8, 2024, 4:54 p.m. UTC | #1
Am Montag, dem 08.04.2024 um 15:53 +0000 schrieb Dariqq:
> Some of the dbus services can't find typelibs.
> 
> * gnu/packages/patches/gnome-shell-wrappable-dbus-services.patch: New
> file
> * gnu/lokal.mk: Register it.
> * gnu/packages/gnome.scm (gnome-shell)[arguments]<#:phases>{'wrap}:
> Also wrap dbus-services.
You can skip [arguments] and just write [#:phases].

> 
> Change-Id: I2c31bf1bd92e281b86c57b06988c6a3793a58d40
> ---
>  gnu/local.mk                                  |  1 +
>  gnu/packages/gnome.scm                        | 13 +++-
>  .../gnome-shell-wrappable-dbus-services.patch | 59
> +++++++++++++++++++
>  3 files changed, 71 insertions(+), 2 deletions(-)
>  create mode 100644 gnu/packages/patches/gnome-shell-wrappable-dbus-
> services.patch
> 
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 255bb870e9..21826c9ec7 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -1376,6 +1376,7 @@ dist_patch_DATA
> =                                         \
>    %D%/packages/patches/gnome-online-miners-tracker-3.patch     \
>    %D%/packages/patches/gnome-settings-daemon-gc.patch          \
>    %D%/packages/patches/gnome-session-support-elogind.patch     \
> +  %D%/packages/patches/gnome-shell-wrappable-dbus-services.patch\
>    %D%/packages/patches/gnome-tweaks-search-paths.patch         \
>    %D%/packages/patches/gnumach-support-noide.patch             \
>    %D%/packages/patches/gnupg-default-pinentry.patch            \
> diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
> index 4934ade3dd..e752232f78 100644
> --- a/gnu/packages/gnome.scm
> +++ b/gnu/packages/gnome.scm
> @@ -9311,7 +9311,9 @@ (define-public gnome-shell
>                                    name "-" version ".tar.xz"))
>                (sha256
>                 (base32
> -               
> "01pw9qnnvh64x56z1gqh0qk6vfn0ihh4zijq23f4bpz9wszlbpwf"))))
> +               
> "01pw9qnnvh64x56z1gqh0qk6vfn0ihh4zijq23f4bpz9wszlbpwf"))
> +              (patches
> +               (search-patches "gnome-shell-wrappable-dbus-
> services.patch"))))
>      (build-system meson-build-system)
>      (arguments
>       (let ((disallowed-references
> @@ -9405,7 +9407,14 @@ (define-public gnome-shell
>                       (wrap-program (string-append #$output "/bin/"
> prog)
>                         `("GUIX_PYTHONPATH"      ":" prefix (,python-
> path))
>                         `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-
> path))))
> -                   '("gnome-shell-perf-tool")))))
> +                   '("gnome-shell-perf-tool"))
> +                  ;; Make sure the dbus services can find typelibs
> +                  (for-each
> +                   (lambda (service)
> +                     (wrap-program (string-append #$output
> "/share/gnome-shell/" service)
> +                       `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-
> path))))
> +                   '("org.gnome.ScreenSaver"
> "org.gnome.Shell.Extensions"
> +                     "org.gnome.Shell.Notifications"
> "org.gnome.Shell.Screencast")))))
LGTM
>              (add-after 'install 'rewire
>                (lambda* (#:key inputs #:allow-other-keys)
>                  (for-each
> diff --git a/gnu/packages/patches/gnome-shell-wrappable-dbus-
> services.patch b/gnu/packages/patches/gnome-shell-wrappable-dbus-
> services.patch
> new file mode 100644
> index 0000000000..67ed6beadb
> --- /dev/null
> +++ b/gnu/packages/patches/gnome-shell-wrappable-dbus-services.patch
> @@ -0,0 +1,59 @@
> +Retrieved from NixOS:
> https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/desktops/gnome/core/gnome-shell/wrap-services.patch
> +---
> +diff --git a/js/dbusServices/dbus-service.in b/js/dbusServices/dbus-
> service.in
> +old mode 100644
> +new mode 100755
> +index 524166102..6d0722a1c
> +--- a/js/dbusServices/dbus-service.in
> ++++ b/js/dbusServices/dbus-service.in
> +@@ -1,3 +1,9 @@
> ++#!@gjs@
> ++
> ++// gjs determines the package name from argv[0], which is .*-
> wrapped
> ++// so we need to override it to the original one.
> ++imports.package._findEffectiveEntryPointName = () => '@service@'
> ++
Is there no other way to specify the entry point?
> + imports.package.start({
> +     name: '@PACKAGE_NAME@',
> +     prefix: '@prefix@',
> +diff --git a/js/dbusServices/dbus-service.service.in
> b/js/dbusServices/dbus-service.service.in
> +index 3b0d09abe..4fd4bb66d 100644
> +--- a/js/dbusServices/dbus-service.service.in
> ++++ b/js/dbusServices/dbus-service.service.in
> +@@ -1,3 +1,3 @@
> + [D-BUS Service]
> + Name=@service@
> +-Exec=@gjs@ @pkgdatadir@/@service@
> ++Exec=@pkgdatadir@/@service@
> +diff --git a/js/dbusServices/meson.build
> b/js/dbusServices/meson.build
> +index eb941ed90..552051e5a 100644
> +--- a/js/dbusServices/meson.build
> ++++ b/js/dbusServices/meson.build
> +@@ -2,6 +2,7 @@ launcherconf = configuration_data()
> + launcherconf.set('PACKAGE_NAME', meson.project_name())
> + launcherconf.set('prefix', prefix)
> + launcherconf.set('libdir', libdir)
> ++launcherconf.set('gjs', gjs.full_path())
> + 
> + dbus_services = {
> +   'org.gnome.Shell.Extensions': 'extensions',
> +@@ -18,16 +19,17 @@ endif
> + config_dir = '@0@/..'.format(meson.current_build_dir())
> + 
> + foreach service, dir : dbus_services
> ++  svc_launcherconf = launcherconf
> ++  svc_launcherconf.set('service', service)
> +   configure_file(
> +     input: 'dbus-service.in',
> +     output: service,
> +-    configuration: launcherconf,
> ++    configuration: svc_launcherconf,
> +     install_dir: pkgdatadir,
> +   )
> + 
> +   serviceconf = configuration_data()
> +   serviceconf.set('service', service)
> +-  serviceconf.set('gjs', gjs.full_path())
> +   serviceconf.set('pkgdatadir', pkgdatadir)
> + 
> +   configure_file(
Cheers
Dariqq April 9, 2024, 3:35 p.m. UTC | #2
Hi,


On 08.04.24 18:54, Liliana Marie Prikler wrote:

>> new file mode 100644 index 0000000000..67ed6beadb --- /dev/null +++
>> b/gnu/packages/patches/gnome-shell-wrappable-dbus-services.patch @@
>> -0,0 +1,59 @@ +Retrieved from NixOS: 
>> https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/desktops/gnome/core/gnome-shell/wrap-services.patch
>>
>> 
+---
>> +diff --git a/js/dbusServices/dbus-service.in
>> b/js/dbusServices/dbus- service.in +old mode 100644 +new mode
>> 100755 +index 524166102..6d0722a1c +---
>> a/js/dbusServices/dbus-service.in ++++
>> b/js/dbusServices/dbus-service.in +@@ -1,3 +1,9 @@ ++#!@gjs@ ++ 
>> ++// gjs determines the package name from argv[0], which is .*- 
>> wrapped ++// so we need to override it to the original one. 
>> ++imports.package._findEffectiveEntryPointName = () => '@service@' 
>> ++
> Is there no other way to specify the entry point?

If it is just about the name in argv[0] what about creating a *-wrapper
instead and leaving the original file untouched rather than the wrapper
replacing the original file?

One quick way would be to rename the wrapper script and original file 
after wrap-program is called, fix the path in the wrapper script and 
adjust the dbus service file to call the *-wrapper instead.

Have a nice day.
Liliana Marie Prikler April 9, 2024, 5:04 p.m. UTC | #3
Am Dienstag, dem 09.04.2024 um 15:35 +0000 schrieb Dariqq:
> Hi,
> 
> 
> On 08.04.24 18:54, Liliana Marie Prikler wrote:
> 
> > > new file mode 100644 index 0000000000..67ed6beadb --- /dev/null
> > > +++
> > > b/gnu/packages/patches/gnome-shell-wrappable-dbus-services.patch
> > > @@
> > > -0,0 +1,59 @@ +Retrieved from NixOS: 
> > > https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/desktops/gnome/core/gnome-shell/wrap-services.patch
> > > 
> > > 
> +---
> > > +diff --git a/js/dbusServices/dbus-service.in
> > > b/js/dbusServices/dbus- service.in +old mode 100644 +new mode
> > > 100755 +index 524166102..6d0722a1c +---
> > > a/js/dbusServices/dbus-service.in ++++
> > > b/js/dbusServices/dbus-service.in +@@ -1,3 +1,9 @@ ++#!@gjs@ ++ 
> > > ++// gjs determines the package name from argv[0], which is .*- 
> > > wrapped ++// so we need to override it to the original one. 
> > > ++imports.package._findEffectiveEntryPointName = () =>
> > > '@service@' 
> > > ++
> > Is there no other way to specify the entry point?
> 
> If it is just about the name in argv[0] what about creating a *-
> wrapper instead and leaving the original file untouched rather than
> the wrapper replacing the original file?
> 
> One quick way would be to rename the wrapper script and original file
> after wrap-program is called, fix the path in the wrapper script and 
> adjust the dbus service file to call the *-wrapper instead.
> 
> Have a nice day.
You can possibly use wrap-script instead of wrap-program, so that you
only need a single file.  I've also written Javascript code to expand
GI_TYPELIB_PATH in other packages already, perhaps you want to copy
that?

Cheers
Dariqq April 10, 2024, 8:07 a.m. UTC | #4
On 09.04.24 19:04, Liliana Marie Prikler wrote:
> You can possibly use wrap-script instead of wrap-program, so that you
> only need a single file.  I've also written Javascript code to expand
> GI_TYPELIB_PATH in other packages already, perhaps you want to copy
> that?
> 
> Cheers

Thanks for the hint with the javascript code. This makes the fix even 
easier as the extra patch is no longer required.

But then what to do with pipewire/GST_PLUGIN_SYSTEM_PATH? We would be 
back at propagating it somewhere.

Also do you have an idea how to communicate to users to enable the 
pipewire home service if they want the screenrecorder to work?

Have a nice day.
Liliana Marie Prikler April 10, 2024, 6:20 p.m. UTC | #5
Am Mittwoch, dem 10.04.2024 um 08:07 +0000 schrieb Dariqq:
> 
> 
> On 09.04.24 19:04, Liliana Marie Prikler wrote:
> > You can possibly use wrap-script instead of wrap-program, so that
> > you only need a single file.  I've also written Javascript code to
> > expand GI_TYPELIB_PATH in other packages already, perhaps you want
> > to copy that?
> > 
> > Cheers
> 
> Thanks for the hint with the javascript code. This makes the fix even
> easier as the extra patch is no longer required.
> 
> But then what to do with pipewire/GST_PLUGIN_SYSTEM_PATH? We would be
> back at propagating it somewhere.
> 
> Also do you have an idea how to communicate to users to enable the 
> pipewire home service if they want the screenrecorder to work?
For pipewire I'm not sure what the problem is, really.  For
GST_PLUGIN_SYSTEM_PATH you can add a wrapper that amends the
environment variable or possibly call some Gst function – either in
Guile with wrap-script or possibly in Javascript.

Cheers
Dariqq April 11, 2024, 9:04 a.m. UTC | #6
Hi,

On 10.04.24 20:20, Liliana Marie Prikler wrote:
> Am Mittwoch, dem 10.04.2024 um 08:07 +0000 schrieb Dariqq:
>>
>>
>> On 09.04.24 19:04, Liliana Marie Prikler wrote:
>>> You can possibly use wrap-script instead of wrap-program, so that
>>> you only need a single file.  I've also written Javascript code to
>>> expand GI_TYPELIB_PATH in other packages already, perhaps you want
>>> to copy that?
>>>
>>> Cheers
>>
>> Thanks for the hint with the javascript code. This makes the fix even
>> easier as the extra patch is no longer required.
>>
>> But then what to do with pipewire/GST_PLUGIN_SYSTEM_PATH? We would be
>> back at propagating it somewhere.
>>
>> Also do you have an idea how to communicate to users to enable the
>> pipewire home service if they want the screenrecorder to work?


> For pipewire I'm not sure what the problem is, really.  For
> GST_PLUGIN_SYSTEM_PATH you can add a wrapper that amends the
> environment variable or possibly call some Gst function – either in
> Guile with wrap-script or possibly in Javascript.

Unfortunately wrap-script does not work as the file 
#$gnome-shell/share/gnome-shell/org.gnome.Shell.Screencast has no 
shebang line set and even if it would ( enabled by the extra patch) gjs 
is not a valid interpreter for wrap_script and trying to change that 
rebuilds everything.


I am currently trying to find out if it is possible to do a similiar 
thing as the GI_TYPELIB_PATH with javascript. Or change the environment 
variable before through another way. My limited javascript knowledge is 
not helping here either.

> Cheers

Have a nice day
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 255bb870e9..21826c9ec7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1376,6 +1376,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/gnome-online-miners-tracker-3.patch	\
   %D%/packages/patches/gnome-settings-daemon-gc.patch		\
   %D%/packages/patches/gnome-session-support-elogind.patch	\
+  %D%/packages/patches/gnome-shell-wrappable-dbus-services.patch\
   %D%/packages/patches/gnome-tweaks-search-paths.patch		\
   %D%/packages/patches/gnumach-support-noide.patch		\
   %D%/packages/patches/gnupg-default-pinentry.patch		\
diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 4934ade3dd..e752232f78 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -9311,7 +9311,9 @@  (define-public gnome-shell
                                   name "-" version ".tar.xz"))
               (sha256
                (base32
-                "01pw9qnnvh64x56z1gqh0qk6vfn0ihh4zijq23f4bpz9wszlbpwf"))))
+                "01pw9qnnvh64x56z1gqh0qk6vfn0ihh4zijq23f4bpz9wszlbpwf"))
+              (patches
+               (search-patches "gnome-shell-wrappable-dbus-services.patch"))))
     (build-system meson-build-system)
     (arguments
      (let ((disallowed-references
@@ -9405,7 +9407,14 @@  (define-public gnome-shell
                      (wrap-program (string-append #$output "/bin/" prog)
                        `("GUIX_PYTHONPATH"      ":" prefix (,python-path))
                        `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))))
-                   '("gnome-shell-perf-tool")))))
+                   '("gnome-shell-perf-tool"))
+                  ;; Make sure the dbus services can find typelibs
+                  (for-each
+                   (lambda (service)
+                     (wrap-program (string-append #$output "/share/gnome-shell/" service)
+                       `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))))
+                   '("org.gnome.ScreenSaver" "org.gnome.Shell.Extensions"
+                     "org.gnome.Shell.Notifications" "org.gnome.Shell.Screencast")))))
             (add-after 'install 'rewire
               (lambda* (#:key inputs #:allow-other-keys)
                 (for-each
diff --git a/gnu/packages/patches/gnome-shell-wrappable-dbus-services.patch b/gnu/packages/patches/gnome-shell-wrappable-dbus-services.patch
new file mode 100644
index 0000000000..67ed6beadb
--- /dev/null
+++ b/gnu/packages/patches/gnome-shell-wrappable-dbus-services.patch
@@ -0,0 +1,59 @@ 
+Retrieved from NixOS: https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/desktops/gnome/core/gnome-shell/wrap-services.patch
+---
+diff --git a/js/dbusServices/dbus-service.in b/js/dbusServices/dbus-service.in
+old mode 100644
+new mode 100755
+index 524166102..6d0722a1c
+--- a/js/dbusServices/dbus-service.in
++++ b/js/dbusServices/dbus-service.in
+@@ -1,3 +1,9 @@
++#!@gjs@
++
++// gjs determines the package name from argv[0], which is .*-wrapped
++// so we need to override it to the original one.
++imports.package._findEffectiveEntryPointName = () => '@service@'
++
+ imports.package.start({
+     name: '@PACKAGE_NAME@',
+     prefix: '@prefix@',
+diff --git a/js/dbusServices/dbus-service.service.in b/js/dbusServices/dbus-service.service.in
+index 3b0d09abe..4fd4bb66d 100644
+--- a/js/dbusServices/dbus-service.service.in
++++ b/js/dbusServices/dbus-service.service.in
+@@ -1,3 +1,3 @@
+ [D-BUS Service]
+ Name=@service@
+-Exec=@gjs@ @pkgdatadir@/@service@
++Exec=@pkgdatadir@/@service@
+diff --git a/js/dbusServices/meson.build b/js/dbusServices/meson.build
+index eb941ed90..552051e5a 100644
+--- a/js/dbusServices/meson.build
++++ b/js/dbusServices/meson.build
+@@ -2,6 +2,7 @@ launcherconf = configuration_data()
+ launcherconf.set('PACKAGE_NAME', meson.project_name())
+ launcherconf.set('prefix', prefix)
+ launcherconf.set('libdir', libdir)
++launcherconf.set('gjs', gjs.full_path())
+ 
+ dbus_services = {
+   'org.gnome.Shell.Extensions': 'extensions',
+@@ -18,16 +19,17 @@ endif
+ config_dir = '@0@/..'.format(meson.current_build_dir())
+ 
+ foreach service, dir : dbus_services
++  svc_launcherconf = launcherconf
++  svc_launcherconf.set('service', service)
+   configure_file(
+     input: 'dbus-service.in',
+     output: service,
+-    configuration: launcherconf,
++    configuration: svc_launcherconf,
+     install_dir: pkgdatadir,
+   )
+ 
+   serviceconf = configuration_data()
+   serviceconf.set('service', service)
+-  serviceconf.set('gjs', gjs.full_path())
+   serviceconf.set('pkgdatadir', pkgdatadir)
+ 
+   configure_file(