-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfirefox.nix
72 lines (64 loc) · 1.81 KB
/
firefox.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
config,
lib,
pkgs,
...
}:
let
cfg = config.dotfiles.firefox;
inherit (pkgs.stdenv) isDarwin;
defaultPackage = if isDarwin then null else pkgs.firefox-bin;
finalPackage = cfg.package.override { extraPolicies = cfg.policies; };
in
{
options.dotfiles.firefox = {
enable = lib.mkEnableOption "Firefox";
package = lib.mkOption {
type = with lib.types; nullOr package;
default = defaultPackage;
description = ''
The Firefox package to use. If `null`, it is assumed that Firefox is
installed outside of Nix.
'';
};
preferences = lib.mkOption {
type =
with lib.types;
attrsOf (oneOf [
str
int
float
bool
]);
default = { };
description = ''
Set default preferences for Firefox.
The list of available options can be viewed by navigating to
`about:config` in Firefox.
'';
};
policies = lib.mkOption {
type = with lib.types; attrsOf anything;
default = { };
description = ''
Configure firefox enterprise policies. On platforms other than macOS,
this option requires the {option}`package` option to be a non `null`
value in order for it to work.
See <https://github.com/mozilla/policy-templates/blob/master/README.md>
for a list of available options.
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.optional (cfg.package != null) finalPackage;
dotfiles.firefox.policies.Preferences = lib.mapAttrs (name: value: {
Value = value;
Status = "default";
}) cfg.preferences;
targets.darwin.defaults = lib.mkIf (isDarwin && cfg.package == null) {
"org.mozilla.firefox" = cfg.policies // {
EnterprisePoliciesEnabled = true;
};
};
};
}