mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-10 18:57:22 +00:00
On Linux, both Thunderbird and Firefox use the same directory to contain native messaging host modules. On this platform, we have to merge both directories with native hosts into one. The patch introduces a separate helper module to manage native host directory generation. Now program modules (firefox, thunderbird) declare native hosts to initialize; while the new helper module determines *where* and *how* to merge them on disc. Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
122 lines
3.7 KiB
Nix
122 lines
3.7 KiB
Nix
{ lib, realPkgs, ... }: {
|
|
imports = [ ../../accounts/email-test-accounts.nix ];
|
|
|
|
_module.args.pkgs = lib.mkForce realPkgs;
|
|
|
|
accounts.email.accounts = {
|
|
"hm@example.com" = {
|
|
thunderbird = {
|
|
enable = true;
|
|
profiles = [ "first" ];
|
|
};
|
|
|
|
aliases = [ "home-manager@example.com" ];
|
|
|
|
gpg.key = "ABC";
|
|
|
|
imap = {
|
|
port = 123;
|
|
tls.enable = true;
|
|
};
|
|
smtp.port = 456;
|
|
|
|
signature = {
|
|
text = "signature";
|
|
showSignature = "append";
|
|
};
|
|
};
|
|
|
|
hm-account = {
|
|
thunderbird = {
|
|
enable = true;
|
|
settings = id: {
|
|
"mail.identity.id_${id}.protectSubject" = false;
|
|
"mail.identity.id_${id}.autoEncryptDrafts" = false;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
# Confirm that both Firefox and Thunderbird can be configured at the same time.
|
|
programs.firefox = { enable = true; };
|
|
|
|
programs.thunderbird = {
|
|
enable = true;
|
|
|
|
# Disable warning so that platforms' behavior is the same
|
|
darwinSetupWarning = false;
|
|
|
|
# Darwin doesn't support wrapped Thunderbird, using unwrapped instead;
|
|
# using -latest- because ESR is currently broken on Darwin
|
|
package = realPkgs.thunderbird-latest-unwrapped;
|
|
|
|
profiles = {
|
|
first = {
|
|
isDefault = true;
|
|
withExternalGnupg = true;
|
|
userChrome = ''
|
|
* { color: blue !important; }
|
|
'';
|
|
userContent = ''
|
|
* { color: red !important; }
|
|
'';
|
|
extraConfig = ''
|
|
user_pref("mail.html_compose", false);
|
|
'';
|
|
};
|
|
|
|
second.settings = {
|
|
"second.setting" = "some-test-setting";
|
|
second.nested.evenFurtherNested = [ 1 2 3 ];
|
|
};
|
|
};
|
|
|
|
nativeMessagingHosts = with realPkgs;
|
|
[
|
|
# NOTE: this is not a real Thunderbird native host module but Firefox; no
|
|
# native hosts are currently packaged for nixpkgs or elsewhere, so we
|
|
# have to improvise. Packaging wise, Firefox and Thunderbird native hosts
|
|
# are identical though. The test doesn't care if the host was meant for
|
|
# either as long as the right paths are present in the package.
|
|
browserpass
|
|
];
|
|
|
|
settings = {
|
|
"general.useragent.override" = "";
|
|
"privacy.donottrackheader.enabled" = true;
|
|
};
|
|
};
|
|
|
|
nmt.script = let
|
|
isDarwin = realPkgs.stdenv.hostPlatform.isDarwin;
|
|
configDir = if isDarwin then "Library/Thunderbird" else ".thunderbird";
|
|
profilesDir = if isDarwin then "${configDir}/Profiles" else "${configDir}";
|
|
nativeHostsDir = if isDarwin then
|
|
"Library/Mozilla/NativeMessagingHosts"
|
|
else
|
|
".mozilla/native-messaging-hosts";
|
|
platform = if isDarwin then "darwin" else "linux";
|
|
in ''
|
|
assertFileExists home-files/${configDir}/profiles.ini
|
|
assertFileContent home-files/${configDir}/profiles.ini \
|
|
${./thunderbird-expected-profiles-${platform}.ini}
|
|
|
|
assertFileExists home-files/${profilesDir}/first/user.js
|
|
assertFileContent home-files/${profilesDir}/first/user.js \
|
|
${./thunderbird-expected-first-${platform}.js}
|
|
|
|
assertFileExists home-files/${profilesDir}/second/user.js
|
|
assertFileContent home-files/${profilesDir}/second/user.js \
|
|
${./thunderbird-expected-second-${platform}.js}
|
|
|
|
assertFileExists home-files/${profilesDir}/first/chrome/userChrome.css
|
|
assertFileContent home-files/${profilesDir}/first/chrome/userChrome.css \
|
|
<(echo "* { color: blue !important; }")
|
|
|
|
assertFileExists home-files/${profilesDir}/first/chrome/userContent.css
|
|
assertFileContent home-files/${profilesDir}/first/chrome/userContent.css \
|
|
<(echo "* { color: red !important; }")
|
|
|
|
assertFileExists home-files/${nativeHostsDir}/com.github.browserpass.native.json
|
|
'';
|
|
}
|