1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

firefox: add darwin support

This commit is contained in:
cmacrae 2019-12-28 22:28:21 +00:00 committed by Robert Helgesson
parent a0ab0b16fe
commit f66cc1b851
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -4,15 +4,35 @@ with lib;
let
inherit (pkgs.stdenv.hostPlatform) isDarwin;
cfg = config.programs.firefox;
mozillaConfigPath =
if isDarwin
then "Library/Application Support/Mozilla"
else ".mozilla";
firefoxConfigPath =
if isDarwin
then "Library/Application Support/Firefox"
else "${mozillaConfigPath}/firefox";
profilesPath =
if isDarwin
then "${firefoxConfigPath}/Profiles"
else firefoxConfigPath;
extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
profiles =
flip mapAttrs' cfg.profiles (_: profile:
nameValuePair "Profile${toString profile.id}" {
Name = profile.name;
Path = profile.path;
Path =
if isDarwin
then "Profiles/${profile.path}"
else profile.path;
IsRelative = 1;
Default = if profile.isDefault then 1 else 0;
}
@ -242,15 +262,18 @@ in
bcfg = setAttrByPath [browserName] fcfg;
package =
if versionAtLeast config.home.stateVersion "19.09"
then cfg.package.override { cfg = fcfg; }
else (pkgs.wrapFirefox.override { config = bcfg; }) cfg.package { };
if isDarwin then
cfg.package
else if versionAtLeast config.home.stateVersion "19.09" then
cfg.package.override { cfg = fcfg; }
else
(pkgs.wrapFirefox.override { config = bcfg; }) cfg.package { };
in
[ package ];
home.file = mkMerge (
[{
".mozilla/${extensionPath}" = mkIf (cfg.extensions != []) (
"${mozillaConfigPath}/${extensionPath}" = mkIf (cfg.extensions != []) (
let
extensionsEnv = pkgs.buildEnv {
name = "hm-firefox-extensions";
@ -262,17 +285,17 @@ in
}
);
".mozilla/firefox/profiles.ini" = mkIf (cfg.profiles != {}) {
"${firefoxConfigPath}/profiles.ini" = mkIf (cfg.profiles != {}) {
text = profilesIni;
};
}]
++ flip mapAttrsToList cfg.profiles (_: profile: {
".mozilla/firefox/${profile.path}/chrome/userChrome.css" =
"${profilesPath}/${profile.path}/chrome/userChrome.css" =
mkIf (profile.userChrome != "") {
text = profile.userChrome;
};
".mozilla/firefox/${profile.path}/user.js" =
"${profilesPath}/${profile.path}/user.js" =
mkIf (profile.settings != {} || profile.extraConfig != "") {
text = mkUserJs profile.settings profile.extraConfig;
};