aboutsummaryrefslogtreecommitdiff
path: root/modules/firefox.home/default.nix
blob: 91e0fb5eae99d9a9b376d4aa95a78aae63d4fa75 (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
{
  config,
  pkgs,
  lib,
  ...
}:
let
  enabled = true;
  # unwrappedFirefoxPackage = pkgs.firefox-unwrapped;
  # configDir = ".mozilla/firefox";
  unwrappedFirefoxPackage = pkgs.librewolf-unwrapped;
  configDir = ".config/librewolf/librewolf";

  firefoxBinName = unwrappedFirefoxPackage.meta.mainProgram;

  extensions = [
    "https://addons.mozilla.org/firefox/downloads/file/3954735/black21-3.0.2.xpi"
    # "https://addons.mozilla.org/firefox/downloads/file/3792127/firefox_dracula-1.0.xpi"
    # "https://addons.mozilla.org/firefox/downloads/file/4261352/tridactyl_vim-1.24.1.xpi"
    # "https://addons.mozilla.org/firefox/downloads/file/4240798/sidetabs-0.66.xpi"
    "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi"

    # dev
    "https://addons.mozilla.org/firefox/downloads/file/4314064/react_devtools-5.3.1.xpi"
    "https://addons.mozilla.org/firefox/downloads/file/3970625/screen_recorder-0.1.8.xpi"

    # others
    "https://addons.mozilla.org/firefox/downloads/file/4332776/languagetool-8.11.6.xpi"
    "https://addons.mozilla.org/firefox/downloads/file/4317971/darkreader-4.9.88.xpi"
  ];

  preferences = (import ./preferences.nix { inherit config; });

  policies = lib.recursiveUpdate (import ./policies.nix { inherit config; }).policies {
    Extensions.Install = extensions;
    Preferences = lib.mapAttrs (_key: val: {
      Status = "locked";
      Value = val;
    }) preferences;
  };

  firefox = pkgs.wrapFirefox unwrappedFirefoxPackage {
    extraPrefs = builtins.readFile ./autoconfig.js;
  };

  profilePath = "default";
in
{
  programs.firefox = {
    enable = enabled;
    package = firefox;
    policies = policies;
  };

  home.packages =
    if config.programs.firefox.enable then
      [ (pkgs.writeShellScriptBin "firefox" ''exec ${firefox}/bin/${firefoxBinName} "$@"'') ]
    else
      [ ];

  home.file =
    if config.programs.firefox.enable then
      {
        # "${configDir}/${profilePath}/chrome".source = ./chrome;

        "${configDir}/profiles.ini".text = lib.generators.toINI { } {
          Profile0 = {
            Name = "default";
            Default = 1;
            IsRelative = 1;
            Path = profilePath;
          };
          General = {
            StartWithLastProfile = 1;
            Version = 2;
          };
        };
      }
    else
      { };
}