From 1ee094637384a4b4993c6d0e1b9303e8ff09b301 Mon Sep 17 00:00:00 2001 From: Carl Hjerpe Date: Fri, 26 Jan 2024 16:16:15 +0100 Subject: [PATCH] firefox: Reimplement FF native messaging Farm links from the selected firefox package, programs.firefox.nativeMessagingHosts and a package with a .keep file for always creating the ~/.mozilla/native-messaging-hosts folder as a regular folder with links in it. Fixes #4959 --- modules/programs/firefox.nix | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index 5984187c8..fcf12b02f 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -22,8 +22,15 @@ let if isDarwin then "${firefoxConfigPath}/Profiles" else firefoxConfigPath; nativeMessagingHostsJoined = pkgs.symlinkJoin { - name = "home_ff_nmhs"; - paths = cfg.package.nativeMessagingHosts or cfg.nativeMessagingHosts; + name = "ff_native-messaging-hosts"; + paths = [ + # Link a .keep file to keep the directory around + (pkgs.writeTextDir "lib/mozilla/native-messaging-hosts/.keep" "") + # Link package configured native messaging hosts (entire Firefox actually) + cfg.finalPackage + ] + # Link user configured native messaging hosts + ++ cfg.nativeMessagingHosts; }; # The extensions path shared by all profiles; will not be supported @@ -718,11 +725,7 @@ in { will be removed in the future. Please change to overriding the package configuration using 'programs.firefox.package' instead. You can refer to its example for how to do this. - '' ++ optional (cfg.package.nativeMessagingHosts or null != null - && cfg.nativeMessagingHosts != [ ]) '' - Using both 'programs.firefox.package.nativeMessagingHosts' and - 'programs.firefox.nativeMessagingHosts' is not supported, the latter will be ignored. - ''; + ''; programs.firefox.finalPackage = wrapPackage cfg.package; @@ -731,8 +734,11 @@ in { home.file = mkMerge ([{ "${firefoxConfigPath}/profiles.ini" = mkIf (cfg.profiles != { }) { text = profilesIni; }; - "${mozillaConfigPath}/native-messaging-hosts".source = - "${nativeMessagingHostsJoined}/lib/mozilla/native-messaging-hosts"; + "${mozillaConfigPath}/native-messaging-hosts" = { + source = + "${nativeMessagingHostsJoined}/lib/mozilla/native-messaging-hosts"; + recursive = true; + }; }] ++ flip mapAttrsToList cfg.profiles (_: profile: { "${profilesPath}/${profile.path}/.keep".text = "";