Open deliciouslytyped opened 5 years ago
Autoconf: After running across the "Mission Control Desktop" keywords here: http://forums.mozillazine.org/viewtopic.php?f=39&t=601199 I finally made some progress figuring this stuff out, which is to say, documentation seems to be extremely spotty unless you assume decade old articles from 55 versions ago are still relevant.
This is the firefox code relating to this "autoconfig" stuff https://dxr.mozilla.org/mozilla-central/source/extensions/pref/autoconfig
❗https://bugzilla.mozilla.org/show_bug.cgi?id=1438247
After some digging, here seems to be some relatively recent input on Autoconfig / MCD / Mission Control Desktop / ??? being officially supported, and used in large enterprises/whatever. This component seems to have a history, and https://bugzilla.mozilla.org/show_bug.cgi?id=1438247#c16 suggests it probably wont get removed immediately (?), so unless Mozilla unilaterally pulls another Quantum this seems like a viable path to (more) declarative configuration?
It also appears to be relevant to all mozilla products.
It needs to be clarified whether the new Windows Group Policy Objects based stuff will be present in parallel to MCD, or whether MCD will be phased out and removed, and we will be left with the (currently?) crippled GPO stuff.
If Autoconfig is a viable option, how stable are the firefox config APIs? Do numeric constants change? (e.g. browser.startup.page
uses a numeric constant like an enum)
Bugzillas: (note these dont show closed issues, need to edit the search)
https://bugzilla.mozilla.org/buglist.cgi?product=Core&component=AutoConfig%20(Mission%20Control%20Desktop) For bugs using an AutoConfig (mozilla.cfg) file to configure Firefox or other Mozilla applications. NOT for Thunderbird Autoconfiguration.
https://bugzilla.mozilla.org/buglist.cgi?quicksearch=mcd
Note: there are mentions of LDAP support, changig these files only has results on next start of firefox (?) TODO: prefs.js vs user.js vs autoconfig.js
@wsmwk @mkaply can you shed some light on the above? I would very much appreciate not needing to poke in the dark. :)
I am looking for a way to do per-profile firefox configuration on linux, with tools (here: Nix) externally imposing configuration settings on firefox, say, by adding a generated "autoconfigure" file.
A common problem with all of those options appears to be that it tries really hard to resolve configuration files relative to the real executable. That defeats the usual methods for configuration through wrapping. The tor-browser-bundle works around this by copying the entire runtime around. Maybe this can be done for the firefox wrapper as well? Then we could have hooks for {policies.json,...} in the wrapper package.
I am also interested in configuring firefox through nix.
Another possible (but rather hacky) solution for this problem is to use user namespaces and bind mounts to work around that. I have a proof of concept script here.
@xaverdh I must have forgotten to mention it, but because autoconf is a js file, it might be possible to just have a global autoconfig that lets you set an environment variable to load further configuration from. IIRC the documentation explicitly suggests the possibility of using env vars. Now, I don't know if this is a good idea, but it sounds like it could work well.
In analogy to the emacs stuff I've been working on, you'd have a site-start.el (a "site-specific configuration file run by emacs before the rest of its init process) that calls out to a path set in an environment variable. (also unsure whether that is a good idea, but it works as a first prototype)
Ok, my hope is to get some more customizability into the firefox wrapper itself. I opened https://github.com/NixOS/nixpkgs/pull/57554 to get things rolling.
Thunderbird policies is just not something on our radar right now. As you found, you can use autoconfig to customize thunderbird (Not to be confused with the thunderbird autoconfig server for configuring email servers).
Though I guess given how nix in general works, it's probably fine to have config stuff set in the firefox root because we can easily just generate new ones? and I think total rebuilds of firefox / wasting disk space could be avoided by just using symlinkJoin or something like that?
Just want to say that it is very nice of you to put some effort into Firefox configuration. At some point I had a quick look at it but gave up quite quickly 😀 I'll help in what way I can.
For what it's worth, I've added an option programs.firefox.extensions
that can be used to declaratively add Firefox extensions. It's not very fancy, simply copies them to the extensions directory where Firefox will see them. Right now the only source of addon packages is from my NUR.
Meanwhile I just realized this might be helpful for anything else in this ecosystem like zotero. (?)
I just merged #719, which adds some profile handling and generation of user.js
. Please have a look and see what you think. See https://rycee.gitlab.io/home-manager/options.html#opt-programs.firefox.profiles for the new options.
A very rough implementation for generating a string from a nested attribute set in that style:
#nix eval -f attrtostr.nix a
with import <nixpkgs> {};
#Huh, this implementation coincidentally ignores options that are empty sets.
let
wot = {
a = {
b = 1;
};
b = 2;
c = {};
d = "asd";
e.f.g = 3;
};
dropLeadingDot = s: builtins.substring 1 (builtins.stringLength s) s;
typeCase = v: ifrec: ifval:
if (builtins.typeOf v == "set")
then ifrec
else ifval;
ifVal = acc: v: "${acc}=${builtins.toString v}";
m = acc: a:
let
acc' = n: "${acc}.${n}";
in
#TODO this is a deprecated function
lib.mapAttrsFlatten (n: v: typeCase v (m (acc' n) v) (ifVal (acc' n) v)) a;
in {
a = lib.traceValSeq ("\n" + (lib.concatMapStringsSep "\n" dropLeadingDot (lib.flatten (m "" wot))));
}
Some stuff about profile up- aand down-grades for more recent foxes: https://discourse.nixos.org/t/why-does-the-following-setup-reset-firefox/4129
I didn't really look into it.
How to import Firefox bookmarks without GUI: https://stackoverflow.com/a/35804955/3057764
Please have a look and see what you think. See https://rycee.gitlab.io/home-manager/options.html#opt-programs.firefox.profiles for the new options.
@rycee FYI in my current .mozilla/firefox/profiles.ini
there is a Version=2
:
[General]
StartWithLastProfile=1
Version=2
Your generated ini currently doesn't generate that (https://github.com/nix-community/home-manager/blob/cf5dad76c1ee452224da39f13129c4ff84351a5c/modules/programs/firefox.nix#L47-L49); I'm wondering whether it should. I couldn't find out what concrete difference it makes so far.
Lol how about no
I hope this is an appropriate place for this. A bit of a brain dump till further notice, I've heard of people working on this but only by proxy so...:
References: [all being researched, will be cleaned later, inconsistencies likely] Nixpkgs issues:
Upstream (firefox):
,
Note:
TODO: check bugzilla (mostly relating to "autoconfig", just for starters there are some interesting things here https://bugzilla.mozilla.org/show_bug.cgi?id=1455601
Current verdict: look into "autoconfig" keywords: autoadmin, autoconfig.jsc, failover.jsc, MCD, Autoconfig, Mission Control Desktop,