nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1diff --git a/common/flatpak-run.c b/common/flatpak-run.c
2index 94ad013..5c9f55e 100644
3--- a/common/flatpak-run.c
4+++ b/common/flatpak-run.c
5@@ -871,6 +871,49 @@ out:
6 return res;
7 }
8
9+static void
10+get_nix_closure (GHashTable *closure, const gchar *source_path)
11+{
12+ if (g_file_test (source_path, G_FILE_TEST_IS_SYMLINK))
13+ {
14+ g_autofree gchar *path = g_malloc(PATH_MAX);
15+ realpath(source_path, path);
16+ if (g_str_has_prefix(path, "/nix/store/"))
17+ {
18+ *strchr(path + strlen("/nix/store/"), '/') = 0;
19+ g_hash_table_add(closure, g_steal_pointer (&path));
20+ }
21+ }
22+ else if (g_file_test (source_path, G_FILE_TEST_IS_DIR))
23+ {
24+ g_autoptr(GDir) dir = g_dir_open(source_path, 0, NULL);
25+ const gchar *file_name;
26+ while ((file_name = g_dir_read_name(dir)))
27+ {
28+ g_autofree gchar *path = g_build_filename (source_path, file_name, NULL);
29+ get_nix_closure (closure, path);
30+ }
31+ }
32+}
33+
34+static void
35+add_nix_store_symlink_targets (FlatpakBwrap *bwrap, const gchar *source_path)
36+{
37+ GHashTable *closure = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
38+
39+ get_nix_closure(closure, source_path);
40+
41+ GHashTableIter iter;
42+ gpointer path;
43+ g_hash_table_iter_init(&iter, closure);
44+ while (g_hash_table_iter_next(&iter, &path, NULL))
45+ {
46+ flatpak_bwrap_add_args (bwrap, "--ro-bind", path, path, NULL);
47+ }
48+
49+ g_hash_table_destroy(closure);
50+}
51+
52 static void
53 add_font_path_args (FlatpakBwrap *bwrap)
54 {
55@@ -898,6 +946,18 @@ add_font_path_args (FlatpakBwrap *bwrap)
56 "\t<remap-dir as-path=\"%s\">/run/host/fonts</remap-dir>\n",
57 SYSTEM_FONTS_DIR);
58 }
59+ else if (g_file_test ("/run/current-system/sw/share/X11/fonts", G_FILE_TEST_EXISTS))
60+ {
61+ add_nix_store_symlink_targets (bwrap, "/run/current-system/sw/share/X11/fonts");
62+ flatpak_bwrap_add_args (bwrap,
63+ "--ro-bind",
64+ "/run/current-system/sw/share/X11/fonts",
65+ "/run/host/fonts",
66+ NULL);
67+ g_string_append_printf (xml_snippet,
68+ "\t<remap-dir as-path=\"%s\">/run/host/fonts</remap-dir>\n",
69+ "/run/current-system/sw/share/X11/fonts");
70+ }
71
72 if (g_file_test ("/usr/local/share/fonts", G_FILE_TEST_EXISTS))
73 {
74@@ -998,6 +1058,13 @@ add_icon_path_args (FlatpakBwrap *bwrap)
75 "--ro-bind", "/usr/share/icons", "/run/host/share/icons",
76 NULL);
77 }
78+ else if (g_file_test ("/run/current-system/sw/share/icons", G_FILE_TEST_IS_DIR))
79+ {
80+ add_nix_store_symlink_targets (bwrap, "/run/current-system/sw/share/icons");
81+ flatpak_bwrap_add_args (bwrap,
82+ "--ro-bind", "/run/current-system/sw/share/icons", "/run/host/share/icons",
83+ NULL);
84+ }
85
86 user_icons_path = g_build_filename (g_get_user_data_dir (), "icons", NULL);
87 user_icons = g_file_new_for_path (user_icons_path);