1 { config, lib, pkgs, ... }:
4 cfg = config.programs.chromium;
6 defaultProfile = lib.filterAttrs (k: v: v != null) {
7 HomepageLocation = cfg.homepageLocation;
8 DefaultSearchProviderEnabled = cfg.defaultSearchProviderEnabled;
9 DefaultSearchProviderSearchURL = cfg.defaultSearchProviderSearchURL;
10 DefaultSearchProviderSuggestURL = cfg.defaultSearchProviderSuggestURL;
11 ExtensionInstallForcelist = cfg.extensions;
20 enable = lib.mkEnableOption "{command}`chromium` policies";
22 enablePlasmaBrowserIntegration = lib.mkEnableOption "Native Messaging Host for Plasma Browser Integration";
24 plasmaBrowserIntegrationPackage = lib.mkPackageOption pkgs [ "plasma5Packages" "plasma-browser-integration" ] { };
26 extensions = lib.mkOption {
27 type = with lib.types; nullOr (listOf str);
29 List of chromium extensions to install.
30 For list of plugins ids see id in url of extensions on
31 [chrome web store](https://chrome.google.com/webstore/category/extensions)
32 page. To install a chromium extension not included in the chrome web
33 store, append to the extension id a semicolon ";" followed by a URL
34 pointing to an Update Manifest XML file. See
35 [ExtensionInstallForcelist](https://cloud.google.com/docs/chrome-enterprise/policies/?policy=ExtensionInstallForcelist)
36 for additional details.
39 example = lib.literalExpression ''
41 "chlffgpmiacpedhhbkiomidkjlcfhogd" # pushbullet
42 "mbniclmhobmnbdlbpiphghaielnnpgdp" # lightshot
43 "gcbommkclmclpchllfjekcdonpmejbdp" # https everywhere
44 "cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin
49 homepageLocation = lib.mkOption {
50 type = lib.types.nullOr lib.types.str;
51 description = "Chromium default homepage";
53 example = "https://nixos.org";
56 defaultSearchProviderEnabled = lib.mkOption {
57 type = lib.types.nullOr lib.types.bool;
58 description = "Enable the default search provider.";
63 defaultSearchProviderSearchURL = lib.mkOption {
64 type = lib.types.nullOr lib.types.str;
65 description = "Chromium default search provider url.";
67 example = "https://encrypted.google.com/search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}ie={inputEncoding}";
70 defaultSearchProviderSuggestURL = lib.mkOption {
71 type = lib.types.nullOr lib.types.str;
72 description = "Chromium default search provider url for suggestions.";
74 example = "https://encrypted.google.com/complete/search?output=chrome&q={searchTerms}";
77 extraOpts = lib.mkOption {
78 type = lib.types.attrs;
80 Extra chromium policy options. A list of available policies
81 can be found in the Chrome Enterprise documentation:
82 <https://cloud.google.com/docs/chrome-enterprise/policies/>
83 Make sure the selected policy is supported on Linux and your browser version.
86 example = lib.literalExpression ''
89 "SyncDisabled" = true;
90 "PasswordManagerEnabled" = false;
91 "SpellcheckEnabled" = true;
92 "SpellcheckLanguage" = [
100 initialPrefs = lib.mkOption {
101 type = lib.types.attrs;
103 Initial preferences are used to configure the browser for the first run.
104 Unlike {option}`programs.chromium.extraOpts`, initialPrefs can be changed by users in the browser settings.
105 More information can be found in the Chromium documentation:
106 <https://www.chromium.org/administrators/configuring-other-preferences/>
109 example = lib.literalExpression ''
120 ###### implementation
123 environment.etc = lib.mkIf cfg.enable {
125 "chromium/native-messaging-hosts/org.kde.plasma.browser_integration.json" = lib.mkIf cfg.enablePlasmaBrowserIntegration
126 { source = "${cfg.plasmaBrowserIntegrationPackage}/etc/chromium/native-messaging-hosts/org.kde.plasma.browser_integration.json"; };
127 "chromium/policies/managed/default.json" = lib.mkIf (defaultProfile != {}) { text = builtins.toJSON defaultProfile; };
128 "chromium/policies/managed/extra.json" = lib.mkIf (cfg.extraOpts != {}) { text = builtins.toJSON cfg.extraOpts; };
129 "chromium/initial_preferences" = lib.mkIf (cfg.initialPrefs != {}) { text = builtins.toJSON cfg.initialPrefs; };
130 # for google-chrome https://www.chromium.org/administrators/linux-quick-start
131 "opt/chrome/native-messaging-hosts/org.kde.plasma.browser_integration.json" = lib.mkIf cfg.enablePlasmaBrowserIntegration
132 { source = "${cfg.plasmaBrowserIntegrationPackage}/etc/opt/chrome/native-messaging-hosts/org.kde.plasma.browser_integration.json"; };
133 "opt/chrome/policies/managed/default.json" = lib.mkIf (defaultProfile != {}) { text = builtins.toJSON defaultProfile; };
134 "opt/chrome/policies/managed/extra.json" = lib.mkIf (cfg.extraOpts != {}) { text = builtins.toJSON cfg.extraOpts; };
136 "brave/policies/managed/default.json" = lib.mkIf (defaultProfile != {}) { text = builtins.toJSON defaultProfile; };
137 "brave/policies/managed/extra.json" = lib.mkIf (cfg.extraOpts != {}) { text = builtins.toJSON cfg.extraOpts; };