aboutsummaryrefslogtreecommitdiffstats
path: root/modules/web/chromium/default.nix
blob: 7901ad6db7e56651deb649db4ea796722738e067 (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{
  config,
  lib,
  pkgs,
  ...
}:
{
  imports = [
    ./browserpass.nix
    ./extensions
  ];

  options.web.chromium = {
    enable = lib.mkEnableOption "Enables chromium.";
    package = lib.mkOption {
      type = lib.types.package;
      readOnly = true;
      default = config.programs.chromium.finalPackage;
      defaultText = lib.literalExpression "config.programs.chromium.finalPackage";
      description = "Package to use for chromium. Defaults to the wrapped finalPackage from programs.chromium.";
    };
    useOpenGL = lib.mkEnableOption ''
      Use OpenGL APIs for graphics acceleration
    '';
  };

  config = lib.mkIf config.web.chromium.enable {
    programs.chromium = {
      enable = true;
      package = pkgs.ungoogled-chromium;
      commandLineArgs =
        let
          extensionDirs = lib.concatStringsSep "," (
            lib.mapAttrsToList (_: ext: ext.drv) config.web.chromium.extensions
          );
        in
        [
          "--force-dark-mode"
          "--force-device-scale-factor=1.15"
          # Don't use the gnome password store
          "--password-store=basic"
          "--load-extension=${extensionDirs}"
        ]
        ++ lib.optionals config.web.chromium.useOpenGL [
          "--use-angle=opengl"
          "--use-cmd-decoder=passthrough"
        ];
    };

    xdg.mimeApps.defaultApplications = {
      "x-scheme-handler/http" = "chromium-browser.desktop";
      "x-scheme-handler/https" = "chromium-browser.desktop";
      "x-scheme-handler/chrome" = "chromium-browser.desktop";
      "text/html" = "chromium-browser.desktop";
      "application/xhtml+xml" = "chromium-browser.desktop";
    };

    xdg.configFile."chromium/Default/Preferences" = {
      force = true;
      text = builtins.toJSON {
        NewTabPage = {
          FooterVisible = false;
        };
        bookmark_bar = {
          show_on_all_tabs = false;
        };
        browser = {
          show_full_urls = true;
          custom_chrome_frame = false;
          theme = {
            color_scheme = 2;
            color_scheme2 = 2; # Used by recent versions
            follows_system_colors = true;
          };
        };
        search = {
          suggest_enabled = false;
        };
        url_handling = {
          show_full_urls = true;
        };
        autofill = {
          profile_enabled = false;
          credit_card_enabled = false;
        };
        vertical_tabs = {
          collapsed_state = true;
          enabled = true;
          enabled_first_time = true;
          uncollapsed_width = 240;
        };
        credentials_enable_service = false;
        credentials_enable_autosignin = false;
        extensions = {
          pinned_extensions = [
            config.web.chromium.extensions.browserpass.id
            config.web.chromium.extensions.darkreader.id
            config.web.chromium.extensions.ublockOrigin.id
            config.web.chromium.extensions.vimium.id
          ];
          theme = {
            id = "";
            system_theme = 1;
            use_system = true;
          };
          ui = {
            developer_mode = true;
          };
        };
        profile = {
          default_content_setting_values = {
            notifications = 2;
          };
        };
        high_efficiency_mode_enabled = true;
      };
    };
  };
}