misc: add librewolf native messaging hosts (#7127)

This commit is contained in:
nakoo 2025-05-30 02:07:27 +00:00 committed by GitHub
parent 8a4b382627
commit 4e9efaa68b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 88 additions and 35 deletions

View file

@ -23,6 +23,12 @@ let
"Library/Application Support/Mozilla/NativeMessagingHosts"
else
".mozilla/native-messaging-hosts";
librewolfNativeMessagingHostsPath =
if isDarwin then
"Library/Application Support/LibreWolf/NativeMessagingHosts"
else
".librewolf/native-messaging-hosts";
in
{
meta.maintainers = with lib.maintainers; [
@ -49,49 +55,77 @@ in
List of Thunderbird native messaging hosts to configure.
'';
};
librewolfNativeMessagingHosts = lib.mkOption {
internal = true;
type = with lib.types; listOf package;
default = [ ];
description = ''
List of Librewolf native messaging hosts to configure.
'';
};
};
config =
lib.mkIf (cfg.firefoxNativeMessagingHosts != [ ] || cfg.thunderbirdNativeMessagingHosts != [ ])
lib.mkIf
(
cfg.firefoxNativeMessagingHosts != [ ]
|| cfg.thunderbirdNativeMessagingHosts != [ ]
|| cfg.librewolfNativeMessagingHosts != [ ]
)
{
home.file =
if isDarwin then
let
firefoxNativeMessagingHostsJoined = pkgs.symlinkJoin {
name = "ff-native-messaging-hosts";
paths = defaultPaths ++ cfg.firefoxNativeMessagingHosts;
};
thunderbirdNativeMessagingHostsJoined = pkgs.symlinkJoin {
name = "th-native-messaging-hosts";
paths = defaultPaths ++ cfg.thunderbirdNativeMessagingHosts;
};
in
{
"${thunderbirdNativeMessagingHostsPath}" = lib.mkIf (cfg.thunderbirdNativeMessagingHosts != [ ]) {
source = "${thunderbirdNativeMessagingHostsJoined}/lib/mozilla/native-messaging-hosts";
let
mkNmhLink =
{ name, nativeMessagingHosts }:
let
packageJoin = pkgs.symlinkJoin {
inherit name;
paths = lib.flatten (
lib.concatLists [
defaultPaths
nativeMessagingHosts
]
);
};
in
lib.mkIf (nativeMessagingHosts != [ ]) {
source = "${packageJoin}/lib/mozilla/native-messaging-hosts";
recursive = true;
ignorelinks = true;
};
in
if isDarwin then
{
"${thunderbirdNativeMessagingHostsPath}" = mkNmhLink {
name = "th-native-messaging-hosts";
nativeMessagingHosts = cfg.thunderbirdNativeMessagingHosts;
};
"${firefoxNativeMessagingHostsPath}" = lib.mkIf (cfg.firefoxNativeMessagingHosts != [ ]) {
source = "${firefoxNativeMessagingHostsJoined}/lib/mozilla/native-messaging-hosts";
recursive = true;
ignorelinks = true;
"${firefoxNativeMessagingHostsPath}" = mkNmhLink {
name = "ff-native-messaging-hosts";
nativeMessagingHosts = cfg.firefoxNativeMessagingHosts;
};
"${librewolfNativeMessagingHostsPath}" = mkNmhLink {
name = "lw-native-messaging-hosts";
nativeMessagingHosts = cfg.librewolfNativeMessagingHosts;
};
}
else
let
nativeMessagingHostsJoined = pkgs.symlinkJoin {
{
"${firefoxNativeMessagingHostsPath}" = mkNmhLink {
name = "mozilla-native-messaging-hosts";
# on Linux, the directory is shared between Firefox and Thunderbird; merge both into one
paths = defaultPaths ++ cfg.firefoxNativeMessagingHosts ++ cfg.thunderbirdNativeMessagingHosts;
nativeMessagingHosts = [
cfg.firefoxNativeMessagingHosts
cfg.thunderbirdNativeMessagingHosts
];
};
in
{
"${firefoxNativeMessagingHostsPath}" = {
source = "${nativeMessagingHostsJoined}/lib/mozilla/native-messaging-hosts";
recursive = true;
ignorelinks = true;
"${librewolfNativeMessagingHostsPath}" = mkNmhLink {
name = "librewolf-native-messaging-hosts";
nativeMessagingHosts = cfg.librewolfNativeMessagingHosts;
};
};
};

View file

@ -1,7 +1,9 @@
{ lib, ... }:
{ lib, config, ... }:
let
inherit (lib) mkRemovedOptionModule;
cfg = config.programs.firefox;
modulePath = [
"programs"
"firefox"
@ -52,4 +54,11 @@ in
modulePath ++ [ "enableIcedTea" ]
) "Support for this option has been removed.")
];
config = lib.mkIf cfg.enable {
mozilla.firefoxNativeMessagingHosts =
cfg.nativeMessagingHosts
# package configured native messaging hosts (entire browser actually)
++ (lib.optional (cfg.finalPackage != null) cfg.finalPackage);
};
}

View file

@ -862,11 +862,6 @@ in
home.packages = lib.optional (cfg.finalPackage != null) cfg.finalPackage;
mozilla.firefoxNativeMessagingHosts =
cfg.nativeMessagingHosts
# package configured native messaging hosts (entire browser actually)
++ (lib.optional (cfg.finalPackage != null) cfg.finalPackage);
home.file = mkMerge (
[
{

View file

@ -1,10 +1,12 @@
{ lib, ... }:
{ lib, config, ... }:
let
modulePath = [
"programs"
"floorp"
];
cfg = config.programs.floorp;
mkFirefoxModule = import ./firefox/mkFirefoxModule.nix;
in
{
@ -26,4 +28,11 @@ in
};
})
];
config = lib.mkIf cfg.enable {
mozilla.firefoxNativeMessagingHosts =
cfg.nativeMessagingHosts
# package configured native messaging hosts (entire browser actually)
++ (lib.optional (cfg.finalPackage != null) cfg.finalPackage);
};
}

View file

@ -34,6 +34,7 @@ in
description = "LibreWolf is a privacy enhanced Firefox fork.";
wrappedPackageName = "librewolf";
unwrappedPackageName = "librewolf-unwrapped";
visible = true;
platforms.linux = {
configPath = ".librewolf";
@ -68,5 +69,10 @@ in
home.file.".librewolf/librewolf.overrides.cfg" = lib.mkIf (cfg.settings != { }) {
text = mkOverridesFile cfg.settings;
};
mozilla.librewolfNativeMessagingHosts =
cfg.nativeMessagingHosts
# package configured native messaging hosts (entire browser actually)
++ (lib.optional (cfg.finalPackage != null) cfg.finalPackage);
};
}