firefox: restore compatibility for extraPolicies

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:

  3feeb77155
  firefox: add support for specifying policies (#4626)
This commit is contained in:
Damien Cassou 2024-01-15 21:55:34 +01:00 committed by Robert Helgesson
parent fa152fd745
commit bf4b576f84
No known key found for this signature in database
GPG Key ID: 96E745BD17AA17ED
2 changed files with 11 additions and 1 deletions

View File

@ -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 { };

View File

@ -9,6 +9,9 @@
programs.firefox = {
enable = true;
policies = { BlockAboutConfig = true; };
package = pkgs.firefox.override {
extraPolicies = { DownloadDirectory = "/foo"; };
};
};
nmt.script = ''
@ -16,11 +19,18 @@
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
'';
};
}