1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-26 03:39:47 +01:00

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 Mikilio
parent 4e7e6e2538
commit c08841a279
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
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 else if versionAtLeast config.home.stateVersion "19.09" then
package.override (old: { package.override (old: {
cfg = old.cfg or { } // fcfg; cfg = old.cfg or { } // fcfg;
extraPolicies = cfg.policies; extraPolicies = (old.extraPolicies or { }) // cfg.policies;
}) })
else else
(pkgs.wrapFirefox.override { config = bcfg; }) package { }; (pkgs.wrapFirefox.override { config = bcfg; }) package { };

View file

@ -9,6 +9,9 @@
programs.firefox = { programs.firefox = {
enable = true; enable = true;
policies = { BlockAboutConfig = true; }; policies = { BlockAboutConfig = true; };
package = pkgs.firefox.override {
extraPolicies = { DownloadDirectory = "/foo"; };
};
}; };
nmt.script = '' nmt.script = ''
@ -16,11 +19,18 @@
config_file="${config.programs.firefox.finalPackage}/lib/firefox/distribution/policies.json" config_file="${config.programs.firefox.finalPackage}/lib/firefox/distribution/policies.json"
assertFileExists "$config_file" assertFileExists "$config_file"
blockAboutConfig_actual_value="$($jq ".policies.BlockAboutConfig" $config_file)" blockAboutConfig_actual_value="$($jq ".policies.BlockAboutConfig" $config_file)"
if [[ $blockAboutConfig_actual_value != "true" ]]; then if [[ $blockAboutConfig_actual_value != "true" ]]; then
fail "Expected '$config_file' to set 'policies.BlockAboutConfig' to true" fail "Expected '$config_file' to set 'policies.BlockAboutConfig' to true"
fi 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
''; '';
}; };
} }