[Feature] Support preconfiguration via Policy#12920
Conversation
|
@alexanderby We'd really appreciate if this got merged. Thanks! <3 Tested on Firefox 128.3.0esr |
|
It'd be nice to document the settings somewhere tho. |
|
Also I can't quite catch the issue, but sometimes theme settings no longer fetch from the policy. In such cases I have to remove the Do I assume correctly that the extension should load new settings from the policy, i.e. just like uBlock? Right now I have to run with this ugly lazy patch ddd532c, but surely it can be done much better. |
Yeah, but I'm not sure where to do it.
I tried changing the settings on my end and couldn't replicate the issue, at least for the 10ish times I changed the policy everything worked. {pkgs, ...}: {
programs.firefox = {
enable = true;
package = pkgs.firefox-esr; # As of writing, version 128.5.1. I think is needed to install extensions from file without signature?
profiles.default = {
isDefault = true;
settings."xpinstall.signatures.required" = false;
};
policies = {
ExtensionSettings."addon@darkreader.org" = {
install_url = "file:///path/to/darkreader/build/release/darkreader-firefox.xpi";
installation_mode = "force_installed";
};
"3rdparty".Extensions."addon@darkreader.org" = {
theme = { # The settings I tried changing back and forth to see if it fails to read
grayscale = 70;
sepia = true;
constrast = 50;
};
};
};
};
}
Yep. |
Well I had to patch it like that: https://git.voronind.com/voronind/nix/src/branch/main/patch/darkreader/Policy.patch My policy configuration: https://git.voronind.com/voronind/nix/src/commit/b979aec1921017e9a003f02ede58a8c168dfa45c/home/program/firefox/default.nix#L303 |
Nice catch! I think then the priority should be changed so managed settings always overwrite local settings. Before I can do that, I'm not sure if I stumbled on an edge case. The function UserStorage.migrateAutomationSettings(SETTINGS);
UserStorage.fillDefaults(SETTINGS);
UserStorage.loadBarrier.resolve(SETTINGS);
return SETTINGS;but the 2nd cases misses the first 2 lines, meaning if we have some local settings that are set to be synced, but sync storage could not be read, we return those local settings without migrations and defaults. |
|
I think that should have fixed the issue, now managed settings always take priority. It would be amazing if you could double check it @voronind-com. If that 2nd case described here should not call |
I'll check it today and report. Thank you very much for looking into this issue. Edit: I've fixed all my issues, testing. |
|
@nenikitov I've tested it multiple times, seems to be working just fine. Thank you <3 |
|
I think that makes this PR feature complete. |
Documentation? |
|
Thanks for the docs, lgtm. |
|
@alexanderby This is quite the feature right here! Gently poking for the first and only time to take a peek at this PR. Thanks for your time! <3 |
|
Could you please tell why do you need this feature? Do you want to install the extension to users in a corporate network and force certain settings? |
Personally I use this to manage my configuration with NixOS in my home infrastructure. Having about a dozen active devices, being able to configure it all only once is very important. If I ever get a new device, when I install OS there, the Dark Reader will be already preconfigured how I need it. Currently DR is the only extension I use that doesn't have this feature (others that I use are UBO, FoxyProxy, Vimium and Bitwarden). Mostly I want to set color theming for web sites, DR is great at this. tl;dr This feature is not that uncommon among browser extensions, and it allows for proper configuration via config files for many-many different use cases. Thanks again! |
Same use case as @voronind-com - sharing browser config between computers. |
I currently only have one device with NixOS and even then, it would still be useful for coordinating a system-wide color scheme. |
|
Heyo, would it be possible to get some movement on this pr? |
|
I donot know why this pr is not closed or merged |
|
@nenikitov can you contribute on my repository to implement pre confrigation via policy iwant to implement same feature on my extension https://github.com/Linkumori/Linkumori-Extension/tree/main |
|
|
@nenikitov Could you be so kind to update this PR to the latest version? I'm honestly considering alternatives to Dark Reader for this very reason. Please tell me if you switched to something else that has policy configurations. |
I'll get to it in a couple of days
No, I'm still using Dark Reader |
|
if this pr becomes a abandonment I might look into creating a pr basing of this one with |
|
It's up to date now |
|
@darkreaderdev and @alexanderby could you be so kind to look at this PR, please? It's been a while. Thanks! |
@voronind-com Can confirm this works for me on Firefox v128.12.0esr. Your config was easy-to-follow and even taught me a couple Nix tricks. Thanks for sharing your patch! |
|
@ahan98 I'm glad it worked out for you! Sorry for the broken links. I'll write an updated guide for NixOS below.
programs.firefox.policies.Preferences = {
"xpinstall.signatures.required" = {
Value = false;
Status = "locked";
};
};
programs.firefox.policies.ExtensionSettings = {
"addon@darkreader.org" = {
install_url = "file://${pkgs.callPackage ./darkreader { }}/latest.xpi";
installation_mode = "force_installed";
};
};
|
|
I am looking into recreating this pr, just because this hasn't been worked on or at least seen to push this pr out. Because this is needed for stylix styling for darkreader and plus I think darkreader having custom styling would be cool since catppucin could make styling for this. |
I has been seen, yet there's no activity, yes. |
In progress need to pull changes from this pr then add coauthor. |

Solves #12619 .
This PR adds configuration via policy for Chrome and Firefox browsers.
I'd be glad if someone could confirm if it works on Safari, Edge, and Thunderbird, I can't test them.