aboutsummaryrefslogtreecommitdiff
This patch lets GLib's GDesktopAppInfo API watch and notice changes
to the Guix user and system profiles.  That way, the list of available
applications shown by the desktop environment is immediately updated
when the user runs "guix install", "guix remove", or "guix system
reconfigure" (see <https://issues.guix.gnu.org/35594>).

It does so by monitoring /var/guix/profiles (for changes to the system
profile) and /var/guix/profiles/per-user/USER (for changes to the user
profile) and crawling their share/applications sub-directory when
changes happen.

diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index f1e2fdd..095c110 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -148,6 +148,7 @@ typedef struct
   gchar                      *alternatively_watching;
   gboolean                    is_config;
   gboolean                    is_setup;
+  gchar                      *guix_profile_watch_dir;
   GFileMonitor               *monitor;
   GHashTable                 *app_names;
   GHashTable                 *mime_tweaks;
@@ -180,6 +181,7 @@ desktop_file_dir_unref (DesktopFileDir *dir)
     {
       desktop_file_dir_reset (dir);
       g_free (dir->path);
+      g_free (dir->guix_profile_watch_dir);
       g_free (dir);
     }
 }
@@ -204,6 +206,13 @@ desktop_file_dir_get_alternative_dir (DesktopFileDir *dir)
 {
   gchar *parent;
 
+  /* If DIR is a profile, watch the specified directory--e.g.,
+   * /var/guix/profiles/per-user/$USER/ for the user profile.  Do not watch
+   * ~/.guix-profile or /run/current-system/profile because GFileMonitor does
+   * not pass IN_DONT_FOLLOW and thus cannot notice any change.  */
+  if (dir->guix_profile_watch_dir != NULL)
+    return g_strdup (dir->guix_profile_watch_dir);
+
   /* If the directory itself exists then we need no alternative. */
   if (g_access (dir->path, R_OK | X_OK) == 0)
     return NULL;
@@ -249,11 +258,11 @@ desktop_file_dir_changed (GFileMonitor      *monitor,
    *
    * If this is a notification for a parent directory (because the
    * desktop directory didn't exist) then we shouldn't fire the signal
-   * unless something actually changed.
+   * unless something actually changed or it's in /var/guix/profiles.
    */
   g_mutex_lock (&desktop_file_dir_lock);
 
-  if (dir->alternatively_watching)
+  if (dir->alternatively_watching && dir->guix_profile_watch_dir == NULL)
     {
       gchar *alternative_dir;
 
@@ -1555,6 +1564,32 @@ desktop_file_dirs_lock (void)
       for (i = 0; dirs[i]; i++)
         g_ptr_array_add (desktop_file_dirs, desktop_file_dir_new (dirs[i]));
 
+      {
+        /* Monitor the system and user profile under /var/guix/profiles and
+         * treat modifications to them as if they were modifications to their
+         * /share sub-directory.  */
+        const gchar *user;
+        DesktopFileDir *system_profile_dir, *user_profile_dir;
+
+        system_profile_dir =
+          desktop_file_dir_new ("/var/guix/profiles/system/profile/share");
+        system_profile_dir->guix_profile_watch_dir = g_strdup ("/var/guix/profiles");
+        g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (system_profile_dir));
+
+        user = g_get_user_name ();
+        if (user != NULL)
+          {
+            gchar *profile_dir, *user_data_dir;
+
+            profile_dir = g_build_filename ("/var/guix/profiles/per-user", user, NULL);
+            user_data_dir = g_build_filename (profile_dir, "guix-profile", "share", NULL);
+            user_profile_dir = desktop_file_dir_new (user_data_dir);
+            user_profile_dir->guix_profile_watch_dir = profile_dir;
+            g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (user_profile_dir));
+            g_free (user_data_dir);
+          }
+      }
+
       /* The list of directories will never change after this, unless
        * g_get_user_config_dir() changes due to %G_TEST_OPTION_ISOLATE_DIRS. */
       desktop_file_dirs_config_dir = user_config_dir;
-page): Likewise. * gnu/installer/newt/network.scm (run-technology-page): Likewise. * gnu/installer/newt/ethernet.scm (run-ethernet-page): Likewise. Ludovic Courtès 2019-01-17installer: Turn "Cancel" buttons into "Exit" buttons....This change and previous ones were, Suggested-by: Thorsten Wilms <t_w_@freenet.de> here: https://lists.gnu.org/archive/html/guix-devel/2018-11/msg00330.html gnu/installer/newt/ethernet.scm: Turn cancel into exit. gnu/installer/newt/final.scm: Ditto. gnu/installer/newt/keymap.scm: Ditto. gnu/installer/newt/locale.scm: Ditto. gnu/installer/newt/network.scm: Ditto. gnu/installer/newt/page.scm: Ditto. gnu/installer/newt/partition.scm: Ditto. gnu/installer/newt/services.scm: Ditto. gnu/installer/newt/timezone.scm: Ditto. gnu/installer/newt/user.scm: Ditto. gnu/installer/newt/wifi.scm: Ditto. Mathieu Othacehe 2019-01-17installer: Fix ethernet connection....* gnu/installer/newt/ethernet.scm (connect-ethernet-service): Return the service passed as parameter. Mathieu Othacehe 2019-01-17gnu: Add graphical installer support....* configure.ac: Require that guile-newt is available. * gnu/installer.scm: New file. * gnu/installer/aux-files/logo.txt: New file. * gnu/installer/build-installer.scm: New file. * gnu/installer/connman.scm: New file. * gnu/installer/keymap.scm: New file. * gnu/installer/locale.scm: New file. * gnu/installer/newt.scm: New file. * gnu/installer/newt/ethernet.scm: New file. * gnu/installer/newt/hostname.scm: New file. * gnu/installer/newt/keymap.scm: New file. * gnu/installer/newt/locale.scm: New file. * gnu/installer/newt/menu.scm: New file. * gnu/installer/newt/network.scm: New file. * gnu/installer/newt/page.scm: New file. * gnu/installer/newt/timezone.scm: New file. * gnu/installer/newt/user.scm: New file. * gnu/installer/newt/utils.scm: New file. * gnu/installer/newt/welcome.scm: New file. * gnu/installer/newt/wifi.scm: New file. * gnu/installer/steps.scm: New file. * gnu/installer/timezone.scm: New file. * gnu/installer/utils.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add previous files. * gnu/system.scm: Export %root-account. * gnu/system/install.scm (%installation-services): Use kmscon instead of linux VT for all tty. (installation-os)[users]: Add the graphical installer as shell of the root account. [packages]: Add font related packages. * po/guix/POTFILES.in: Add installer files. Mathieu Othacehe