1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2025-01-24 18:05:03 +01:00

firefox: implement native messaging hosts

Fixes #1586
Fixes #1487

Co-authored-by: Carl Hjerpe <git@hjerpe.xyz>
Co-authored-by: Robert Helgesson <robert@rycee.net>
This commit is contained in:
Ujp8LfXBJ6wCPR 2024-01-24 23:22:57 +01:00 committed by Mikilio
parent b64804f20a
commit 87bf943237
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F

View file

@ -21,6 +21,11 @@ let
profilesPath = profilesPath =
if isDarwin then "${firefoxConfigPath}/Profiles" else firefoxConfigPath; if isDarwin then "${firefoxConfigPath}/Profiles" else firefoxConfigPath;
nativeMessagingHostsJoined = pkgs.symlinkJoin {
name = "home_ff_nmhs";
paths = cfg.package.nativeMessagingHosts or cfg.nativeMessagingHosts;
};
# The extensions path shared by all profiles; will not be supported # The extensions path shared by all profiles; will not be supported
# by future Firefox versions. # by future Firefox versions.
extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"; extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
@ -228,6 +233,15 @@ in {
''; '';
}; };
nativeMessagingHosts = mkOption {
type = types.listOf types.package;
default = [ ];
description = ''
Additional packages containing native messaging hosts that should be
made available to Firefox extensions.
'';
};
finalPackage = mkOption { finalPackage = mkOption {
type = with types; nullOr package; type = with types; nullOr package;
readOnly = true; readOnly = true;
@ -673,7 +687,11 @@ 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;
@ -682,6 +700,8 @@ 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 =
"${nativeMessagingHostsJoined}/lib/mozilla/native-messaging-hosts";
}] ++ flip mapAttrsToList cfg.profiles (_: profile: { }] ++ flip mapAttrsToList cfg.profiles (_: profile: {
"${profilesPath}/${profile.path}/.keep".text = ""; "${profilesPath}/${profile.path}/.keep".text = "";