gnu: ungoogled-chromium: Add search path for installed extensions.
authorMarius Bakke <marius@gnu.org>
Fri, 23 Oct 2020 08:17:21 +0000 (10:17 +0200)
committerMarius Bakke <marius@gnu.org>
Thu, 5 Nov 2020 01:20:24 +0000 (02:20 +0100)
* gnu/packages/patches/ungoogled-chromium-extension-search-path.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.
* gnu/packages/chromium.scm (%guix-patches): New variable.
(ungoogled-chromium-snippet): Apply %GUIX-PATCHES.
(ungoogled-chromium)[arguments]: Don't hard-code extensions directory.
[native-search-paths]: New field.

gnu/local.mk
gnu/packages/chromium.scm
gnu/packages/patches/ungoogled-chromium-extension-search-path.patch [new file with mode: 0644]

index 2a994bd..72f81a9 100644 (file)
@@ -1653,6 +1653,7 @@ dist_patch_DATA =                                         \
   %D%/packages/patches/u-boot-riscv64-fix-extlinux.patch       \
   %D%/packages/patches/ucx-tcp-iface-ioctl.patch               \
   %D%/packages/patches/udiskie-no-appindicator.patch           \
+  %D%/packages/patches/ungoogled-chromium-extension-search-path.patch  \
   %D%/packages/patches/ungoogled-chromium-system-nspr.patch    \
   %D%/packages/patches/unison-fix-ocaml-4.08.patch             \
   %D%/packages/patches/unknown-horizons-python-3.8-distro.patch        \
index f32a779..b219170 100644 (file)
      (base32
       "18p9a7qffmy8m03nqva7maalgil13lj2mn0s56v3crbs4wk4lalj"))))
 
+(define %guix-patches
+  (list (local-file (search-patch "ungoogled-chromium-system-nspr.patch"))
+        (local-file (search-patch "ungoogled-chromium-extension-search-path.patch"))))
+
 ;; This is a source 'snippet' that does the following:
 ;; *) Applies various patches for unbundling purposes and libstdc++ compatibility.
 ;; *) Runs the ungoogled patch-, domain substitution-, and scrubbing scripts.
                       (invoke "patch" "-p1" "--force" "--input"
                               patch "--no-backup-if-mismatch"))
                     (append '#+%debian-patches '#+%arch-patches
-                            '#+(list (local-file
-                                      (search-patch
-                                       "ungoogled-chromium-system-nspr.patch")))))
+                            '#+%guix-patches))
 
           (with-directory-excursion #+%ungoogled-origin
             (format #t "Ungooglifying...~%")
                        (find-files (string-append "third_party/webrtc/modules"
                                                   "/audio_coding/codecs/opus")))
 
-             (substitute* "chrome/common/chrome_paths.cc"
-               (("/usr/share/chromium/extensions")
-                ;; TODO: Add ~/.guix-profile.
-                "/run/current-system/profile/share/chromium/extensions"))
-
              ;; Many files try to include ICU headers from "third_party/icu/...".
              ;; Remove the "third_party/" prefix to use system headers instead.
              (substitute* (find-files "chrome" "\\.cc$")
        ("udev" ,eudev)
        ("valgrind" ,valgrind)
        ("vulkan-headers" ,vulkan-headers)))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "CHROMIUM_EXTENSION_DIRECTORY")
+            (separator #f)              ;single entry
+            (files '("share/chromium/extensions")))))
 
     ;; Building Chromium takes ... a very long time.  On a single core, a busy
     ;; mid-end x86 system may need more than 24 hours to complete the build.
diff --git a/gnu/packages/patches/ungoogled-chromium-extension-search-path.patch b/gnu/packages/patches/ungoogled-chromium-extension-search-path.patch
new file mode 100644 (file)
index 0000000..5ce219c
--- /dev/null
@@ -0,0 +1,28 @@
+Look for extensions in $CHROMIUM_EXTENSION_DIRECTORY instead of
+/usr/share/chromium/extensions.
+
+--- a/chrome/common/chrome_paths.cc
++++ b/chrome/common/chrome_paths.cc
+@@ -4,6 +4,7 @@
+ #include "chrome/common/chrome_paths.h"
++#include "base/environment.h"
+ #include "base/files/file_util.h"
+ #include "base/logging.h"
+ #include "base/native_library.h"
+@@ -511,7 +512,13 @@
+ #endif
+ #if defined(OS_LINUX) || defined(OS_CHROMEOS)
+     case chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS: {
+-      cur = base::FilePath(kFilepathSinglePrefExtensions);
++      std::unique_ptr<base::Environment> environment(base::Environment::Create());
++      std::string extension_dir;
++      if (environment->GetVar("CHROMIUM_EXTENSION_DIRECTORY", &extension_dir)) {
++        cur = base::FilePath(extension_dir);
++      } else {
++        cur = base::FilePath(kFilepathSinglePrefExtensions);
++      }
+       break;
+     }
+ #endif