firefox: fix starting with non-default profile #6244
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When home-manager manages the Firefox configuration, the
profiles.ini
file in~/.mozilla/firefox/
is immutable. Any attempt by Firefox to update it fails accordingly. Currently, when multiple profiles are defined, it is not possible to choose a non-default one by passing a-Profile
option to Firefox, or by usingfirefox -ProfileManager
: if the user chooses a non-default profile, Firefox tries to update theprofile.ini
with this choice, which fails because of the file's immutability, and Firefox refuses to start up. The user is shown an error sayingAn unexpected error has prevented your changes from being saved.
.Currently, the setting to save the profile choice back to
profiles.ini
is hardcoded in home-manager. This Pull Request changes that, so the file is never updated with the user choice.This fixes the cases where a user attempts to start a non-default profile.
I think this is also matches home-manager philosophy nicely: because we define what the default profile is in our home-manager config, the user should not be able to change that in the firefox gui, because then the active configuration would diverge from what's defined in home-manager. As a matter of fact, the user currently can't change the default anyway, as trying to do so results in an error, but the user should be able to choose a profile for an individual Firefox instance.
The Firefox Profile Manager GUI (that you get by starting Firefox with the
-ProfileManager
option) has a check box to decide whether to "use the selected profile without asking at startup", i.e. make it the new default. This is currently ticked (because it's hardcoded in home-manager asStartWithLastProfile = 1
). If it stays ticked, choosing any profile other than the default results in the error. Unticking this box will also not help, because now Firefox would attempt to updateprofiles.ini
withStartWithLastProfile=0
.Either way, when home-manager manages the Firefox config for us, we cannot have Firefox update
profiles.ini
, and therefore we cannot change the default profile through Firefox's GUI.With this fix, choosing a different profile on the command line (
firefox -Profile foo
) or via the GUI (firefox -ProfileManager
) now works. The user will still get an error when they tick the checkbox to "use the selected profile without asking at startup", because that results in an attempt to updateprofiles.ini
. Also, it would mean that the chosen default profile would diverge from the setting in the user's home-manager config - so not allowing this seems sensible.Checklist
Change is backwards compatible.
Code formatted with
./format
.Code tested through
nix-shell --pure tests -A run.all
ornix develop --ignore-environment .#all
using Flakes.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new moduleAdded myself as module maintainer. See example.Maintainer CC
@brckd @rycee @offlinehacker