1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 02:39:48 +01:00

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
This commit is contained in:
Carl Hjerpe 2024-01-26 16:16:15 +01:00
parent c7ce343d9b
commit 690764d2dc

View file

@ -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 = "";