Wed, 06 May 2020 08:52:30 +0000
You can interpret "fixing" here in any of its popular senses.
Presenting one approach for getting from freshly installed Firefox to something you'd actually want to use (preferences, extensions, etc) without tedious manual configuration.
- any prefs (these correspond to the options in
about:config) we put in the
user.jsfile in the current profile will override other values of the same options set anywhere else. We need to parse
~/.mozilla/firefox/profiles.ini, find the current profile, and write that file
- to ensure that extensions are installed, we can use the Enterprise
Firefox feature : write a
policies.jsonfile that "goes into a directory called
distributionwithin the Firefox installation directory."
- that doesn't help us directly, as the said directory on Nix is
/nix/store/which is read-only - but: there's a pref to make Firefox look for it somewhere else. If
toolkit.policies.perUserDiris true, it will instead search in
/run/user/nnn/firefox- see bug 1583466
- So: we have a small Python program that finds the profile and writes the prefs js, then writes the policies.json into
- This directory is ephemeral - for one thing it's on a ramdisk, and
for another there's systemd magic that wipes it out when you
logout. So we need a way to recreate it on login, and what better
than a systemd
If our package derivation puts this file in
$out/share/systemd/user/then it will end up somewhere systemd can see it.
So it's not wholly automatic but it's pretty close: after running
nix-env -r -iA nixos.desktop - which is my usual way of setting up
my user environment - I needed to do
systemctl --user enable
configure-firefox. Yes, I could probably put that in my
nixos configuration.nix but then I've coupled my per-user and per-host
configuration and I'm not completely certain I want to do that.