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

firefox: add support for specifying policies (#4626)

This commit is contained in:
Damien Cassou 2023-11-17 23:54:39 +01:00 committed by Mikilio
parent cfc5345c0d
commit 3b73b79da6
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
3 changed files with 42 additions and 1 deletions

View file

@ -169,7 +169,10 @@ let
else if isDarwin then else if isDarwin then
package package
else if versionAtLeast config.home.stateVersion "19.09" then else if versionAtLeast config.home.stateVersion "19.09" then
package.override (old: { cfg = old.cfg or { } // fcfg; }) package.override (old: {
cfg = old.cfg or { } // fcfg;
extraPolicies = cfg.policies;
})
else else
(pkgs.wrapFirefox.override { config = bcfg; }) package { }; (pkgs.wrapFirefox.override { config = bcfg; }) package { };
@ -230,6 +233,17 @@ in {
description = "Resulting Firefox package."; description = "Resulting Firefox package.";
}; };
policies = mkOption {
type = types.attrsOf jsonFormat.type;
default = { };
description =
"[See list of policies](https://mozilla.github.io/policy-templates/).";
example = {
DefaultDownloadDirectory = "\${home}/Downloads";
BlockAboutConfig = true;
};
};
profiles = mkOption { profiles = mkOption {
type = types.attrsOf (types.submodule ({ config, name, ... }: { type = types.attrsOf (types.submodule ({ config, name, ... }: {
options = { options = {

View file

@ -4,4 +4,5 @@
firefox-deprecated-native-messenger = ./deprecated-native-messenger.nix; firefox-deprecated-native-messenger = ./deprecated-native-messenger.nix;
firefox-duplicate-profile-ids = ./duplicate-profile-ids.nix; firefox-duplicate-profile-ids = ./duplicate-profile-ids.nix;
firefox-duplicate-container-ids = ./duplicate-container-ids.nix; firefox-duplicate-container-ids = ./duplicate-container-ids.nix;
firefox-policies = ./policies.nix;
} }

View file

@ -0,0 +1,26 @@
{ config, lib, pkgs, ... }:
{
imports = [ ./setup-firefox-mock-overlay.nix ];
config = lib.mkIf config.test.enableBig {
home.stateVersion = "23.05";
programs.firefox = {
enable = true;
policies = { BlockAboutConfig = true; };
};
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
'';
};
}