I need to deploy my Firefox configured and with extensions in NixOS. I want to do that declaratively (in configuration.nix) and I do not want to use home-manager.

Firefox looks for the config in /nix/store/<hash>-firefox-unwrapped-74.0.1/lib/firefox/distribution/policies.json (verified with strace).

Hence the question: How do I add this file to the Firefox nixpkgs package? (Bonus question: How do I get a file from my Github Repo there?)

I'm rather new to NixOs. I consulted the manuals about overriding, overlays, wrapping and more but I couldn't manage to pull it off. I tried with both firefox, firefox-bin and firefox-unwrapped.

2 Answers 2


Since NixOS 21.05 (commit) it is now easy to create a custom Firefox package with some policy values set using, for example,

pkgs.wrapFirefox pkgs.firefox-unwrapped {
  extraPolicies = {
    DisableFirefoxStudies = true;
    DisablePocket = true;

where pkgs is the Nixpkgs package set.


I took a glance at the firefox Nix expressions and didn't see a way to provide a policies.json.

If you modify the package such that you can provide the policy as an input to the derivation, it would work but then users would be forced the burden of compiling Firefox; Because the file would be a build input.

If Firefox provides a way to specify where to find the policies file at runtime, that might be an ideal solution. Otherwise, you can add a patch to the Firefox package which modifies the source code to look for the policies file at say... /etc/firefox/policies.json. With that change in place, you can use the environment NixOS module in /etc/nixos/configuration.nix to create the policies. Something like this:

environment.etc."firefox/policies".text = "INSERT POLICY HERE";
  • 2
    After a look in the source code, I actually found a way: setting the preference toolkit.policies.perUserDir to true will result in Firefox looking for /run/user/1000/firefox/policies.
    – MemAllox
    Commented Apr 16, 2020 at 13:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .