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/run/host/fonts\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/run/host/fonts\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);
href='/guix/commit/tests/store-deduplication.scm?id=472a0e82a52a3d5d841e1dfad6b13e26082a5750'>daemon: Do not deduplicate files smaller than 8 KiB....Files smaller than 8 KiB typically represent ~70% of the entries in
/gnu/store/.links but only contribute to ~4% of the space savings
afforded by deduplication.
Not considering these files for deduplication speeds up file insertion
in the store and, more importantly, leaves 'removeUnusedLinks' with
fewer entries to traverse, thereby speeding it up proportionally.
Partly fixes <https://issues.guix.gnu.org/24937>.
* config-daemon.ac: Remove symlink hard link check and CAN_LINK_SYMLINK
definition.
* guix/store/deduplication.scm (%deduplication-minimum-size): New
variable.
(deduplicate)[loop]: Do not recurse when FILE's size is below
%DEDUPLICATION-MINIMUM-SIZE.
(dump-port): New procedure.
(dump-file/deduplicate)[hash]: Turn into...
[dump-and-compute-hash]: ... this thunk.
Call 'deduplicate' only when SIZE is greater than
%DEDUPLICATION-MINIMUM-SIZE; otherwise call 'dump-port'.
* nix/libstore/gc.cc (LocalStore::removeUnusedLinks): Drop files where
st.st_size < deduplicationMinSize.
* nix/libstore/local-store.hh (deduplicationMinSize): New declaration.
* nix/libstore/optimise-store.cc (deduplicationMinSize): New variable.
(LocalStore::optimisePath_): Return when PATH is a symlink or smaller
than 'deduplicationMinSize'.
* tests/derivations.scm ("identical files are deduplicated"): Produce
files bigger than %DEDUPLICATION-MINIMUM-SIZE.
* tests/nar.scm ("restore-file-set with directories (signed, valid)"):
Likewise.
* tests/store-deduplication.scm ("deduplicate, below %deduplication-minimum-size"):
New test.
("deduplicate", "deduplicate, ENOSPC"): Produce files bigger than
%DEDUPLICATION-MINIMUM-SIZE.
* tests/store.scm ("substitute, deduplication"): Likewise.
Ludovic Courtès |
2020-12-15 | deduplicate: Create the '.links' directory lazily....This avoids repeated (mkdir-p "/gnu/store/.links") calls when
deduplicating lots of files.
* guix/store/deduplication.scm (deduplicate): Remove initial call to
'mkdir-p'. Add ENOENT case in 'link' exception handler. Reindent.
* tests/store-deduplication.scm ("deduplicate, ENOSPC"): Check
for (<= links 4) to account for the initial 'link' call.
| Ludovic Courtès |
2020-12-15 | store-copy: 'populate-store' can optionally deduplicate files....Until now deduplication was performed as an additional pass after
copying files, which involve re-traversing all the files that had just
been copied.
* guix/store/deduplication.scm (copy-file/deduplicate): New procedure.
* tests/store-deduplication.scm ("copy-file/deduplicate"): New test.
* guix/build/store-copy.scm (populate-store): Add #:deduplicate?
parameter and honor it.
* tests/gexp.scm ("gexp->derivation, store copy"): Pass #:deduplicate? #f
to 'populate-store'.
* gnu/build/image.scm (initialize-root-partition): Pass #:deduplicate?
to 'populate-store'. Pass #:deduplicate? #f to 'register-closure'.
* gnu/build/vm.scm (root-partition-initializer): Likewise.
* gnu/build/install.scm (populate-single-profile-directory): Pass
#:deduplicate? #f to 'populate-store'.
* gnu/build/linux-initrd.scm (build-initrd): Likewise.
* guix/scripts/pack.scm (self-contained-tarball)[import-module?]: New
procedure.
[build]: Pass it as an argument to 'source-module-closure'.
* guix/scripts/pack.scm (squashfs-image)[build]: Wrap in
'with-extensions'.
* gnu/system/linux-initrd.scm (expression->initrd)[import-module?]: New
procedure.
[builder]: Pass it to 'source-module-closure'.
* gnu/system/install.scm (cow-store-service-type)[import-module?]: New
procedure. Pass it to 'source-module-closure'.
| Ludovic Courtès |