summaryrefslogtreecommitdiff
path: root/gnu/packages/patches/flatpak-fix-fonts-icons.patch
diff options
context:
space:
mode:
authorZheng Junjie <[email protected]>2024-03-31 14:43:07 +0800
committerZheng Junjie <[email protected]>2024-06-29 12:03:00 +0800
commit9590fa7617c704d1e1e22eaaa8dcd678c3f0aad6 (patch)
tree69cb6273a901f1e241707fb2d636f48a1f0c2d07 /gnu/packages/patches/flatpak-fix-fonts-icons.patch
parent385fb14f6482a955fbef4d4b21fccb3473beddd8 (diff)
gnu: flatpak: Pass system icons and fonts.
* gnu/packages/patches/flatpak-fix-fonts-icons.patch: New patch. * gnu/packages/package-management.scm(flatpak): Use it. * gnu/local.mk(dist_patch_DATA): Register it. Change-Id: I0359d0d9bf10120a8b784c910c50d0e4a9b7a616
Diffstat (limited to 'gnu/packages/patches/flatpak-fix-fonts-icons.patch')
-rw-r--r--gnu/packages/patches/flatpak-fix-fonts-icons.patch89
1 files changed, 89 insertions, 0 deletions
diff --git a/gnu/packages/patches/flatpak-fix-fonts-icons.patch b/gnu/packages/patches/flatpak-fix-fonts-icons.patch
new file mode 100644
index 0000000000..5b9d855b2e
--- /dev/null
+++ b/gnu/packages/patches/flatpak-fix-fonts-icons.patch
@@ -0,0 +1,89 @@
+modify from https://github.com/NixOS/nixpkgs/pull/262462
+
+diff --git a/common/flatpak-run.c b/common/flatpak-run.c
+index 94ad013..5c9f55e 100644
+--- a/common/flatpak-run.c
++++ b/common/flatpak-run.c
+@@ -871,6 +871,49 @@ out:
+ return res;
+ }
+
++static void
++get_gnu_closure (GHashTable *closure, const gchar *source_path)
++{
++ if (g_file_test (source_path, G_FILE_TEST_IS_SYMLINK))
++ {
++ g_autofree gchar *path = g_malloc(PATH_MAX);
++ realpath(source_path, path);
++ if (g_str_has_prefix(path, "/gnu/store/"))
++ {
++ *strchr(path + strlen("/gnu/store/"), '/') = 0;
++ g_hash_table_add(closure, g_steal_pointer (&path));
++ }
++ }
++ else if (g_file_test (source_path, G_FILE_TEST_IS_DIR))
++ {
++ g_autoptr(GDir) dir = g_dir_open(source_path, 0, NULL);
++ const gchar *file_name;
++ while ((file_name = g_dir_read_name(dir)))
++ {
++ g_autofree gchar *path = g_build_filename (source_path, file_name, NULL);
++ get_gnu_closure (closure, path);
++ }
++ }
++}
++
++static void
++add_gnu_store_symlink_targets (FlatpakBwrap *bwrap, const gchar *source_path)
++{
++ GHashTable *closure = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
++
++ get_gnu_closure(closure, source_path);
++
++ GHashTableIter iter;
++ gpointer path;
++ g_hash_table_iter_init(&iter, closure);
++ while (g_hash_table_iter_next(&iter, &path, NULL))
++ {
++ flatpak_bwrap_add_args (bwrap, "--ro-bind", path, path, NULL);
++ }
++
++ g_hash_table_destroy(closure);
++}
++
+ static void
+ add_font_path_args (FlatpakBwrap *bwrap)
+ {
+@@ -898,6 +946,18 @@ add_font_path_args (FlatpakBwrap *bwrap)
+ "\t<remap-dir as-path=\"%s\">/run/host/fonts</remap-dir>\n",
+ SYSTEM_FONTS_DIR);
+ }
++ else if (g_file_test ("/run/current-system/profile/share/fonts", G_FILE_TEST_EXISTS))
++ {
++ add_gnu_store_symlink_targets (bwrap, "/run/current-system/profile/share/fonts");
++ flatpak_bwrap_add_args (bwrap,
++ "--ro-bind",
++ "/run/current-system/profile/share/fonts",
++ "/run/host/fonts",
++ NULL);
++ g_string_append_printf (xml_snippet,
++ "\t<remap-dir as-path=\"%s\">/run/host/fonts</remap-dir>\n",
++ "/run/current-system/profile/share/fonts");
++ }
+
+ if (g_file_test ("/usr/local/share/fonts", G_FILE_TEST_EXISTS))
+ {
+@@ -998,6 +1058,13 @@ add_icon_path_args (FlatpakBwrap *bwrap)
+ "--ro-bind", "/usr/share/icons", "/run/host/share/icons",
+ NULL);
+ }
++ else if (g_file_test ("/run/current-system/profile/share/icons", G_FILE_TEST_IS_DIR))
++ {
++ add_gnu_store_symlink_targets (bwrap, "/run/current-system/profile/share/icons");
++ flatpak_bwrap_add_args (bwrap,
++ "--ro-bind", "/run/current-system/profile/share/icons", "/run/host/share/icons",
++ NULL);
++ }
+
+ user_icons_path = g_build_filename (g_get_user_data_dir (), "icons", NULL);
+ user_icons = g_file_new_for_path (user_icons_path);