firefox: set non-default configPath on darwin

On macOS 27+, wrapped package will have no Mozilla signature and will
fail to access the default datadir. Move users with recent stateVersion
to a non-default datadir recommended by:

https://github.com/NixOS/nixpkgs/pull/556611

Users with existing profiles under default datadir will have to migrate
them to a different location on macOS 27 upgrade. Migrating existing
directory is out of scope for Home Manager.
This commit is contained in:
Ihar Hrachyshka
2026-08-27 18:51:59 -04:00
committed by Austin Horstman
parent 922a645e84
commit c41f8b81d1
3 changed files with 98 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
{
expectedDarwinPath,
packageIsNull ? false,
stateVersion,
}:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.firefox;
expectedConfigPath =
if pkgs.stdenv.hostPlatform.isDarwin then expectedDarwinPath else ".config/mozilla/firefox";
expectedAppDataDir =
if
pkgs.stdenv.hostPlatform.isDarwin && !packageIsNull && lib.versionAtLeast stateVersion "26.11"
then
"${config.home.homeDirectory}/${expectedDarwinPath}"
else
null;
firefoxPackage = lib.makeOverridable (
{
cfg ? { },
extraPolicies ? { },
pkcs11Modules ? [ ],
appDataDir ? null,
}:
builtins.deepSeq
[
cfg
extraPolicies
pkcs11Modules
]
(
config.lib.test.mkStubPackage {
name = "firefox-config-path-darwin-default-test-stub";
extraAttrs = {
browserName = "firefox";
inherit appDataDir;
meta.mainProgram = "firefox";
};
}
)
) { };
in
{
config = lib.mkIf config.test.enableBig {
home.stateVersion = stateVersion;
programs.firefox = {
enable = true;
package = if packageIsNull then null else firefoxPackage;
profiles.test.settings."general.smoothScroll" = false;
};
assertions = [
{
assertion = cfg.configPath == expectedConfigPath;
message = "Firefox configPath has an unexpected default";
}
{
assertion = cfg.finalPackage == null || cfg.finalPackage.appDataDir == expectedAppDataDir;
message = "Firefox wrapper received an unexpected appDataDir";
}
];
mozilla.firefoxNativeMessagingHosts = lib.mkForce [ ];
};
}

View File

@@ -4,6 +4,19 @@
"firefox-bookmarks-legacy-attrset-warning" = ./bookmarks-legacy-attrset-warning.nix;
"firefox-config-path-explicit-legacy" = ./config-path-explicit-legacy.nix;
"firefox-config-path-explicit-xdg" = ./config-path-explicit-xdg.nix;
"firefox-config-path-darwin-default-current" = import ./config-path-darwin-default.nix {
expectedDarwinPath = "Library/Application Support/org.nixos.firefox";
stateVersion = "26.11";
};
"firefox-config-path-darwin-default-legacy" = import ./config-path-darwin-default.nix {
expectedDarwinPath = "Library/Application Support/Firefox";
stateVersion = "26.05";
};
"firefox-config-path-darwin-default-null-package" = import ./config-path-darwin-default.nix {
expectedDarwinPath = "Library/Application Support/Firefox";
packageIsNull = true;
stateVersion = "26.11";
};
"firefox-config-path-wrapper-absolute" = import ./config-path-wrapper.nix {
absolute = true;
configPath = "Library/Application Support/org.nixos.firefox";