1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-09-21 05:47:29 +02: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 committed by Mikilio
parent 17b2a3a2a7
commit 1ee0946373
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F

View file

@ -22,8 +22,15 @@ let
if isDarwin then "${firefoxConfigPath}/Profiles" else firefoxConfigPath; if isDarwin then "${firefoxConfigPath}/Profiles" else firefoxConfigPath;
nativeMessagingHostsJoined = pkgs.symlinkJoin { nativeMessagingHostsJoined = pkgs.symlinkJoin {
name = "home_ff_nmhs"; name = "ff_native-messaging-hosts";
paths = cfg.package.nativeMessagingHosts or cfg.nativeMessagingHosts; 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 # 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 will be removed in the future. Please change to overriding the package
configuration using 'programs.firefox.package' instead. You can refer to configuration using 'programs.firefox.package' instead. You can refer to
its example for how to do this. 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; programs.firefox.finalPackage = wrapPackage cfg.package;
@ -731,8 +734,11 @@ in {
home.file = mkMerge ([{ home.file = mkMerge ([{
"${firefoxConfigPath}/profiles.ini" = "${firefoxConfigPath}/profiles.ini" =
mkIf (cfg.profiles != { }) { text = profilesIni; }; mkIf (cfg.profiles != { }) { text = profilesIni; };
"${mozillaConfigPath}/native-messaging-hosts".source = "${mozillaConfigPath}/native-messaging-hosts" = {
"${nativeMessagingHostsJoined}/lib/mozilla/native-messaging-hosts"; source =
"${nativeMessagingHostsJoined}/lib/mozilla/native-messaging-hosts";
recursive = true;
};
}] ++ flip mapAttrsToList cfg.profiles (_: profile: { }] ++ flip mapAttrsToList cfg.profiles (_: profile: {
"${profilesPath}/${profile.path}/.keep".text = ""; "${profilesPath}/${profile.path}/.keep".text = "";