diff options
| author | Brice Waegeneire <brice@waegenei.re> | 2025-06-22 15:18:13 +0200 |
|---|---|---|
| committer | Hilton Chain <hako@ultrarare.space> | 2025-06-25 03:04:28 +0800 |
| commit | 4d6bc7d0dce675f55de7cebf0c918428f88e5755 (patch) | |
| tree | 2bdf5c119575efbca6fadb8faac72adb5aedb18e | |
| parent | 554e6e6b43a597bf96cc04b948546abdd8d069e3 (diff) | |
nongnu: firefox: Fix GPU decoding.
* nongnu/packages/patches/firefox-esr-add-store-to-rdd-allowlist.patch: New
file.
* nongnu/packages/mozilla.scm (firefox-esr)[source]<patches>: Add it.
[#:phases]<wrap-glxtest>: New phase ported from Guix's librewolf package.
<wrap-program>: Remove whitelist manipulation.
[inputs]: Add pciutils.
* nongnu/packages/patches/firefox-add-store-to-rdd-allowlist.patch: New file.
* nongnu/packages/mozilla.scm (firefox)[source]<patches>: Add it.
Fixes: https://gitlab.com/nonguix/nonguix/-/issues/389
Signed-off-by: Hilton Chain <hako@ultrarare.space>
Modified-by: Hilton Chain <hako@ultrarare.space>
| -rw-r--r-- | nongnu/packages/mozilla.scm | 45 | ||||
| -rw-r--r-- | nongnu/packages/patches/firefox-add-store-to-rdd-allowlist.patch | 36 | ||||
| -rw-r--r-- | nongnu/packages/patches/firefox-esr-add-store-to-rdd-allowlist.patch | 36 |
3 files changed, 95 insertions, 22 deletions
diff --git a/nongnu/packages/mozilla.scm b/nongnu/packages/mozilla.scm index c15d4dd..35cf6e1 100644 --- a/nongnu/packages/mozilla.scm +++ b/nongnu/packages/mozilla.scm | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | ;;; Copyright © 2020-2025 Jonathan Brielmaier <jonathan.brielmaier@web.de> | 17 | ;;; Copyright © 2020-2025 Jonathan Brielmaier <jonathan.brielmaier@web.de> |
| 18 | ;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com> | 18 | ;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com> |
| 19 | ;;; Copyright © 2021 pineapples <guixuser6392@protonmail.com> | 19 | ;;; Copyright © 2021 pineapples <guixuser6392@protonmail.com> |
| 20 | ;;; Copyright © 2021, 2024 Brice Waegeneire <brice@waegenei.re> | 20 | ;;; Copyright © 2021, 2024, 2025 Brice Waegeneire <brice@waegenei.re> |
| 21 | ;;; Copyright © 2021, 2022, 2023 John Kehayias <john.kehayias@protonmail.com> | 21 | ;;; Copyright © 2021, 2022, 2023 John Kehayias <john.kehayias@protonmail.com> |
| 22 | ;;; Copyright © 2022 Pierre Langlois <pierre.langlois@gmx.com> | 22 | ;;; Copyright © 2022 Pierre Langlois <pierre.langlois@gmx.com> |
| 23 | ;;; Copyright © 2023-2025 Tomas Volf <wolf@wolfsden.cz> | 23 | ;;; Copyright © 2023-2025 Tomas Volf <wolf@wolfsden.cz> |
| @@ -63,6 +63,7 @@ | |||
| 63 | #:use-module (gnu packages node) | 63 | #:use-module (gnu packages node) |
| 64 | #:use-module (gnu packages nss) | 64 | #:use-module (gnu packages nss) |
| 65 | #:use-module (gnu packages perl) | 65 | #:use-module (gnu packages perl) |
| 66 | #:use-module (gnu packages pciutils) | ||
| 66 | #:use-module (gnu packages pkg-config) | 67 | #:use-module (gnu packages pkg-config) |
| 67 | #:use-module (gnu packages pulseaudio) | 68 | #:use-module (gnu packages pulseaudio) |
| 68 | #:use-module (gnu packages python) | 69 | #:use-module (gnu packages python) |
| @@ -106,7 +107,8 @@ | |||
| 106 | %load-path) | 107 | %load-path) |
| 107 | patch)) | 108 | patch)) |
| 108 | '("firefox-esr-compare-paths.patch" | 109 | '("firefox-esr-compare-paths.patch" |
| 109 | "firefox-esr-use-system-wide-dir.patch"))) | 110 | "firefox-esr-use-system-wide-dir.patch" |
| 111 | "firefox-esr-add-store-to-rdd-allowlist.patch"))) | ||
| 110 | ;; XXX: 75 Mo (800+ Mo uncompressed) of unused tests. | 112 | ;; XXX: 75 Mo (800+ Mo uncompressed) of unused tests. |
| 111 | ;; Removing it makes it possible to compile on some systems. | 113 | ;; Removing it makes it possible to compile on some systems. |
| 112 | (modules '((guix build utils))) | 114 | (modules '((guix build utils))) |
| @@ -351,6 +353,20 @@ | |||
| 351 | (string-drop hash 8))))))) | 353 | (string-drop hash 8))))))) |
| 352 | (replace 'install | 354 | (replace 'install |
| 353 | (lambda _ (invoke "./mach" "install"))) | 355 | (lambda _ (invoke "./mach" "install"))) |
| 356 | (add-after 'install 'wrap-glxtest | ||
| 357 | ;; glxtest uses dlopen() to load mesa and pci | ||
| 358 | ;; libs, wrap it to set LD_LIBRARY_PATH. | ||
| 359 | (lambda* (#:key inputs outputs #:allow-other-keys) | ||
| 360 | (let* ((out (assoc-ref outputs "out")) | ||
| 361 | (lib (string-append out "/lib")) | ||
| 362 | (libs (map | ||
| 363 | (lambda (lib-name) | ||
| 364 | (string-append (assoc-ref inputs | ||
| 365 | lib-name) | ||
| 366 | "/lib")) | ||
| 367 | '("mesa" "pciutils")))) | ||
| 368 | (wrap-program (car (find-files lib "^glxtest$")) | ||
| 369 | `("LD_LIBRARY_PATH" prefix ,libs))))) | ||
| 354 | (add-after 'install 'wrap-program | 370 | (add-after 'install 'wrap-program |
| 355 | (lambda* (#:key inputs outputs #:allow-other-keys) | 371 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 356 | ;; The following two functions are from Guix's icecat package in | 372 | ;; The following two functions are from Guix's icecat package in |
| @@ -380,28 +396,11 @@ | |||
| 380 | ;; and libva depend on). | 396 | ;; and libva depend on). |
| 381 | (pciaccess-lib (string-append (assoc-ref inputs "libpciaccess") | 397 | (pciaccess-lib (string-append (assoc-ref inputs "libpciaccess") |
| 382 | "/lib")) | 398 | "/lib")) |
| 383 | ;; VA-API is run in the RDD (Remote Data Decoder) sandbox | ||
| 384 | ;; and must be explicitly given access to files it needs. | ||
| 385 | ;; Rather than adding the whole store (as Nix had | ||
| 386 | ;; upstream do, see | ||
| 387 | ;; <https://github.com/NixOS/nixpkgs/pull/165964> and | ||
| 388 | ;; linked upstream patches), we can just follow the | ||
| 389 | ;; runpaths of the needed libraries to add everything to | ||
| 390 | ;; LD_LIBRARY_PATH. These will then be accessible in the | ||
| 391 | ;; RDD sandbox. | ||
| 392 | ;; TODO: Properly handle the runpath of libraries needed | ||
| 393 | ;; (for RDD) recursively, so the explicit libpciaccess | ||
| 394 | ;; can be removed. | ||
| 395 | (rdd-whitelist | ||
| 396 | (map (cut string-append <> "/") | ||
| 397 | (delete-duplicates | ||
| 398 | (append-map runpaths-of-input | ||
| 399 | '("mesa" "ffmpeg"))))) | ||
| 400 | (pulseaudio-lib (string-append (assoc-ref inputs "pulseaudio") | 399 | (pulseaudio-lib (string-append (assoc-ref inputs "pulseaudio") |
| 401 | "/lib")) | 400 | "/lib")) |
| 402 | ;; For sharing on Wayland | 401 | ;; For sharing on Wayland |
| 403 | (pipewire-lib (string-append (assoc-ref inputs "pipewire") | 402 | (pipewire-lib (string-append (assoc-ref inputs "pipewire") |
| 404 | "/lib")) | 403 | "/lib")) |
| 405 | ;; For U2F and WebAuthn | 404 | ;; For U2F and WebAuthn |
| 406 | (eudev-lib (string-append (assoc-ref inputs "eudev") "/lib")) | 405 | (eudev-lib (string-append (assoc-ref inputs "eudev") "/lib")) |
| 407 | (gtk-share (string-append (assoc-ref inputs "gtk+") | 406 | (gtk-share (string-append (assoc-ref inputs "gtk+") |
| @@ -409,7 +408,7 @@ | |||
| 409 | (wrap-program (car (find-files lib "^firefox$")) | 408 | (wrap-program (car (find-files lib "^firefox$")) |
| 410 | `("LD_LIBRARY_PATH" prefix (,mesa-lib ,libnotify-lib ,libva-lib | 409 | `("LD_LIBRARY_PATH" prefix (,mesa-lib ,libnotify-lib ,libva-lib |
| 411 | ,pciaccess-lib ,pulseaudio-lib ,eudev-lib | 410 | ,pciaccess-lib ,pulseaudio-lib ,eudev-lib |
| 412 | ,@rdd-whitelist ,pipewire-lib)) | 411 | ,pipewire-lib)) |
| 413 | `("XDG_DATA_DIRS" prefix (,gtk-share)) | 412 | `("XDG_DATA_DIRS" prefix (,gtk-share)) |
| 414 | `("MOZ_LEGACY_PROFILES" = ("1")) | 413 | `("MOZ_LEGACY_PROFILES" = ("1")) |
| 415 | `("MOZ_ALLOW_DOWNGRADE" = ("1")))))) | 414 | `("MOZ_ALLOW_DOWNGRADE" = ("1")))))) |
| @@ -485,6 +484,7 @@ | |||
| 485 | nspr-4.32 | 484 | nspr-4.32 |
| 486 | ;; nss | 485 | ;; nss |
| 487 | pango | 486 | pango |
| 487 | pciutils | ||
| 488 | pipewire | 488 | pipewire |
| 489 | pixman | 489 | pixman |
| 490 | pulseaudio | 490 | pulseaudio |
| @@ -550,7 +550,8 @@ Release (ESR) version.") | |||
| 550 | patch)) | 550 | patch)) |
| 551 | '("firefox-restore-desktop-files.patch" | 551 | '("firefox-restore-desktop-files.patch" |
| 552 | "firefox-ge-138-compare-paths.patch" | 552 | "firefox-ge-138-compare-paths.patch" |
| 553 | "firefox-use-system-wide-dir.patch"))) | 553 | "firefox-use-system-wide-dir.patch" |
| 554 | "firefox-add-store-to-rdd-allowlist.patch"))) | ||
| 554 | ;; XXX: 75 Mo (800+ Mo uncompressed) of unused tests. | 555 | ;; XXX: 75 Mo (800+ Mo uncompressed) of unused tests. |
| 555 | ;; Removing it makes it possible to compile on some systems. | 556 | ;; Removing it makes it possible to compile on some systems. |
| 556 | (modules '((guix build utils))) | 557 | (modules '((guix build utils))) |
diff --git a/nongnu/packages/patches/firefox-add-store-to-rdd-allowlist.patch b/nongnu/packages/patches/firefox-add-store-to-rdd-allowlist.patch new file mode 100644 index 0000000..4bdaa7d --- /dev/null +++ b/nongnu/packages/patches/firefox-add-store-to-rdd-allowlist.patch | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | diff --git a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp | ||
| 2 | index 4eff5e6..42171eb 100644 | ||
| 3 | --- a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp | ||
| 4 | +++ b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp | ||
| 5 | @@ -476,6 +476,7 @@ void SandboxBrokerPolicyFactory::InitContentPolicy() { | ||
| 6 | // Various places where fonts reside | ||
| 7 | policy->AddTree(rdonly, "/usr/X11R6/lib/X11/fonts"); | ||
| 8 | policy->AddTree(rdonly, "/nix/store"); | ||
| 9 | + policy->AddTree(rdonly, "/gnu/store"); | ||
| 10 | // https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/blob/e434e680d22260f277f4a30ec4660ed32b591d16/files/fontconfig-flatpak.conf | ||
| 11 | policy->AddTree(rdonly, "/run/host/fonts"); | ||
| 12 | policy->AddTree(rdonly, "/run/host/user-fonts"); | ||
| 13 | @@ -485,6 +486,7 @@ void SandboxBrokerPolicyFactory::InitContentPolicy() { | ||
| 14 | // Bug 1848615 | ||
| 15 | policy->AddPath(rdonly, "/usr"); | ||
| 16 | policy->AddPath(rdonly, "/nix"); | ||
| 17 | + policy->AddPath(rdonly, "/gnu"); | ||
| 18 | |||
| 19 | AddLdconfigPaths(policy); | ||
| 20 | AddLdLibraryEnvPaths(policy); | ||
| 21 | @@ -934,6 +936,7 @@ SandboxBrokerPolicyFactory::GetRDDPolicy(int aPid) { | ||
| 22 | policy->AddTree(rdonly, "/usr/lib64"); | ||
| 23 | policy->AddTree(rdonly, "/run/opengl-driver/lib"); | ||
| 24 | policy->AddTree(rdonly, "/nix/store"); | ||
| 25 | + policy->AddTree(rdonly, "/gnu/store"); | ||
| 26 | |||
| 27 | // Bug 1647957: memory reporting. | ||
| 28 | AddMemoryReporting(policy.get(), aPid); | ||
| 29 | @@ -1079,6 +1082,7 @@ SandboxBrokerPolicyFactory::GetUtilityProcessPolicy(int aPid) { | ||
| 30 | // Required to make sure ffmpeg loads properly, this is already existing on | ||
| 31 | // Content and RDD | ||
| 32 | policy->AddTree(rdonly, "/nix/store"); | ||
| 33 | + policy->AddTree(rdonly, "/gnu/store"); | ||
| 34 | |||
| 35 | // glibc will try to stat64("/") while populating nsswitch database | ||
| 36 | // https://sourceware.org/git/?p=glibc.git;a=blob;f=nss/nss_database.c;h=cf0306adc47f12d9bc761ab1b013629f4482b7e6;hb=9826b03b747b841f5fc6de2054bf1ef3f5c4bdf3#l396 | ||
diff --git a/nongnu/packages/patches/firefox-esr-add-store-to-rdd-allowlist.patch b/nongnu/packages/patches/firefox-esr-add-store-to-rdd-allowlist.patch new file mode 100644 index 0000000..6ae18c3 --- /dev/null +++ b/nongnu/packages/patches/firefox-esr-add-store-to-rdd-allowlist.patch | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | diff --git a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp | ||
| 2 | index 0e5358e68e..efbde9616e 100644 | ||
| 3 | --- a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp | ||
| 4 | +++ b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp | ||
| 5 | @@ -452,6 +452,7 @@ void SandboxBrokerPolicyFactory::InitContentPolicy() { | ||
| 6 | // Various places where fonts reside | ||
| 7 | policy->AddDir(rdonly, "/usr/X11R6/lib/X11/fonts"); | ||
| 8 | policy->AddDir(rdonly, "/nix/store"); | ||
| 9 | + policy->AddDir(rdonly, "/gnu/store"); | ||
| 10 | // https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/blob/e434e680d22260f277f4a30ec4660ed32b591d16/files/fontconfig-flatpak.conf | ||
| 11 | policy->AddDir(rdonly, "/run/host/fonts"); | ||
| 12 | policy->AddDir(rdonly, "/run/host/user-fonts"); | ||
| 13 | @@ -461,6 +462,7 @@ void SandboxBrokerPolicyFactory::InitContentPolicy() { | ||
| 14 | // Bug 1848615 | ||
| 15 | policy->AddPath(rdonly, "/usr"); | ||
| 16 | policy->AddPath(rdonly, "/nix"); | ||
| 17 | + policy->AddPath(rdonly, "/gnu"); | ||
| 18 | |||
| 19 | AddLdconfigPaths(policy); | ||
| 20 | AddLdLibraryEnvPaths(policy); | ||
| 21 | @@ -920,6 +922,7 @@ SandboxBrokerPolicyFactory::GetRDDPolicy(int aPid) { | ||
| 22 | policy->AddDir(rdonly, "/usr/lib64"); | ||
| 23 | policy->AddDir(rdonly, "/run/opengl-driver/lib"); | ||
| 24 | policy->AddDir(rdonly, "/nix/store"); | ||
| 25 | + policy->AddDir(rdonly, "/gnu/store"); | ||
| 26 | |||
| 27 | // Bug 1647957: memory reporting. | ||
| 28 | AddMemoryReporting(policy.get(), aPid); | ||
| 29 | @@ -1043,6 +1046,7 @@ SandboxBrokerPolicyFactory::GetUtilityProcessPolicy(int aPid) { | ||
| 30 | // Required to make sure ffmpeg loads properly, this is already existing on | ||
| 31 | // Content and RDD | ||
| 32 | policy->AddDir(rdonly, "/nix/store"); | ||
| 33 | + policy->AddDir(rdonly, "/gnu/store"); | ||
| 34 | |||
| 35 | // glibc will try to stat64("/") while populating nsswitch database | ||
| 36 | // https://sourceware.org/git/?p=glibc.git;a=blob;f=nss/nss_database.c;h=cf0306adc47f12d9bc761ab1b013629f4482b7e6;hb=9826b03b747b841f5fc6de2054bf1ef3f5c4bdf3#l396 | ||
