about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/flatpak
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2024-04-10 20:43:08 +0200
committerAlyssa Ross <hi@alyssa.is>2024-04-10 20:43:08 +0200
commit69bfdf2484041b9d242840c4e5017b4703383bb0 (patch)
treed8bdaa69e7990d7d6f09b594b3c425f742acd2d0 /nixpkgs/pkgs/development/libraries/flatpak
parentc8aee4b4363b6bf905a521b05b7476960e8286c8 (diff)
parentd8fe5e6c92d0d190646fb9f1056741a229980089 (diff)
downloadnixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar
nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.gz
nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.bz2
nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.lz
nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.xz
nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.zst
nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.zip
Merge commit 'd8fe5e6c'
Conflicts:
	nixpkgs/pkgs/build-support/go/module.nix
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/flatpak')
-rw-r--r--nixpkgs/pkgs/development/libraries/flatpak/default.nix4
-rw-r--r--nixpkgs/pkgs/development/libraries/flatpak/fix-fonts-icons.patch87
2 files changed, 91 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/flatpak/default.nix b/nixpkgs/pkgs/development/libraries/flatpak/default.nix
index 005890a3d4a6..1786d84e7a4b 100644
--- a/nixpkgs/pkgs/development/libraries/flatpak/default.nix
+++ b/nixpkgs/pkgs/development/libraries/flatpak/default.nix
@@ -97,6 +97,10 @@ stdenv.mkDerivation (finalAttrs: {
     # The icon validator needs to access the gdk-pixbuf loaders in the Nix store
     # and cannot bind FHS paths since those are not available on NixOS.
     finalAttrs.passthru.icon-validator-patch
+
+    # Try mounting fonts and icons from NixOS locations if FHS locations don't exist.
+    # https://github.com/NixOS/nixpkgs/issues/119433
+    ./fix-fonts-icons.patch
   ];
 
   nativeBuildInputs = [
diff --git a/nixpkgs/pkgs/development/libraries/flatpak/fix-fonts-icons.patch b/nixpkgs/pkgs/development/libraries/flatpak/fix-fonts-icons.patch
new file mode 100644
index 000000000000..31a96d88b7dd
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/flatpak/fix-fonts-icons.patch
@@ -0,0 +1,87 @@
+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_nix_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, "/nix/store/"))
++        {
++          *strchr(path + strlen("/nix/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_nix_closure (closure, path);
++        }
++    }
++}
++
++static void
++add_nix_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_nix_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/sw/share/X11/fonts", G_FILE_TEST_EXISTS))
++    {
++      add_nix_store_symlink_targets (bwrap, "/run/current-system/sw/share/X11/fonts");
++      flatpak_bwrap_add_args (bwrap,
++                              "--ro-bind",
++                              "/run/current-system/sw/share/X11/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/sw/share/X11/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/sw/share/icons", G_FILE_TEST_IS_DIR))
++    {
++      add_nix_store_symlink_targets (bwrap, "/run/current-system/sw/share/icons");
++      flatpak_bwrap_add_args (bwrap,
++                              "--ro-bind", "/run/current-system/sw/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);