about summary refs log tree commit diff
path: root/nixos/modules/programs/thunderbird.nix
blob: b15c1df6094393b36d5d3a3a67cec711773ff2fb (plain) (blame)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
  pkgs,
  config,
  lib,
  ...
}:
let
  cfg = config.programs.thunderbird;
  policyFormat = pkgs.formats.json { };
  policyDoc = "https://github.com/thunderbird/policy-templates";
in
{
  options.programs.thunderbird = {
    enable = lib.mkEnableOption "Thunderbird mail client";

    package = lib.mkPackageOption pkgs "thunderbird" { };

    policies = lib.mkOption {
      type = policyFormat.type;
      default = { };
      description = ''
        Group policies to install.

        See [Thunderbird's documentation](${policyDoc})
        for a list of available options.

        This can be used to install extensions declaratively! Check out the
        documentation of the `ExtensionSettings` policy for details.

      '';
    };

    preferences = lib.mkOption {
      type =
        with lib.types;
        attrsOf (oneOf [
          bool
          int
          str
        ]);
      default = { };
      description = ''
        Preferences to set from `about:config`.

        Some of these might be able to be configured more ergonomically
        using policies.
      '';
    };

    preferencesStatus = lib.mkOption {
      type = lib.types.enum [
        "default"
        "locked"
        "user"
        "clear"
      ];
      default = "locked";
      description = ''
        The status of `thunderbird.preferences`.

        `status` can assume the following values:
        - `"default"`: Preferences appear as default.
        - `"locked"`: Preferences appear as default and can't be changed.
        - `"user"`: Preferences appear as changed.
        - `"clear"`: Value has no effect. Resets to factory defaults on each startup.
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = [ cfg.package ];

    environment.etc =
      let
        policiesJSON = policyFormat.generate "thunderbird-policies.json" { inherit (cfg) policies; };
      in
      lib.mkIf (cfg.policies != { }) { "thunderbird/policies/policies.json".source = policiesJSON; };

    programs.thunderbird.policies = {
      DisableAppUpdate = true;
      Preferences = builtins.mapAttrs (_: value: {
        Value = value;
        Status = cfg.preferencesStatus;
      }) cfg.preferences;
    };
  };

  meta.maintainers = with lib.maintainers; [ nydragon ];
}