Skip to content

Commit

Permalink
firefox: restore compatibility for extraPolicies
Browse files Browse the repository at this point in the history
This commit makes it possible to specify Firefox' extraPolicies
through:

    programs.firefox.package = pkgs.firefox.override {
      extraPolicies = {... }
    }

This was possible in the past but was broken by:

  3feeb77
  firefox: add support for specifying policies (#4626)
  • Loading branch information
DamienCassou authored and rycee committed Jan 16, 2024
1 parent fa152fd commit bf4b576
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/programs/firefox.nix
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ let
else if versionAtLeast config.home.stateVersion "19.09" then
package.override (old: {
cfg = old.cfg or { } // fcfg;
extraPolicies = cfg.policies;
extraPolicies = (old.extraPolicies or { }) // cfg.policies;
})
else
(pkgs.wrapFirefox.override { config = bcfg; }) package { };
Expand Down
10 changes: 10 additions & 0 deletions tests/modules/programs/firefox/policies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@
programs.firefox = {
enable = true;
policies = { BlockAboutConfig = true; };
package = pkgs.firefox.override {
extraPolicies = { DownloadDirectory = "/foo"; };
};
};

nmt.script = ''
jq=${lib.getExe pkgs.jq}
config_file="${config.programs.firefox.finalPackage}/lib/firefox/distribution/policies.json"
assertFileExists "$config_file"
blockAboutConfig_actual_value="$($jq ".policies.BlockAboutConfig" $config_file)"
if [[ $blockAboutConfig_actual_value != "true" ]]; then
fail "Expected '$config_file' to set 'policies.BlockAboutConfig' to true"
fi
downloadDirectory_actual_value="$($jq ".policies.DownloadDirectory" $config_file)"
if [[ $downloadDirectory_actual_value != "\"/foo\"" ]]; then
fail "Expected '$config_file' to set 'policies.DownloadDirectory' to \"/foo\""
fi
'';
};
}

0 comments on commit bf4b576

Please sign in to comment.