6 cfg = config.programs.chromium;
8 defaultProfile = filterAttrs (k: v: v != null) {
9 HomepageLocation = cfg.homepageLocation;
10 DefaultSearchProviderEnabled = cfg.defaultSearchProviderEnabled;
11 DefaultSearchProviderSearchURL = cfg.defaultSearchProviderSearchURL;
12 DefaultSearchProviderSuggestURL = cfg.defaultSearchProviderSuggestURL;
13 ExtensionInstallForcelist = cfg.extensions;
22 enable = mkEnableOption (lib.mdDoc "{command}`chromium` policies");
24 extensions = mkOption {
25 type = types.listOf types.str;
26 description = lib.mdDoc ''
27 List of chromium extensions to install.
28 For list of plugins ids see id in url of extensions on
29 [chrome web store](https://chrome.google.com/webstore/category/extensions)
30 page. To install a chromium extension not included in the chrome web
31 store, append to the extension id a semicolon ";" followed by a URL
32 pointing to an Update Manifest XML file. See
33 [ExtensionInstallForcelist](https://cloud.google.com/docs/chrome-enterprise/policies/?policy=ExtensionInstallForcelist)
34 for additional details.
37 example = literalExpression ''
39 "chlffgpmiacpedhhbkiomidkjlcfhogd" # pushbullet
40 "mbniclmhobmnbdlbpiphghaielnnpgdp" # lightshot
41 "gcbommkclmclpchllfjekcdonpmejbdp" # https everywhere
42 "cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin
47 homepageLocation = mkOption {
48 type = types.nullOr types.str;
49 description = lib.mdDoc "Chromium default homepage";
51 example = "https://nixos.org";
54 defaultSearchProviderEnabled = mkOption {
55 type = types.nullOr types.bool;
56 description = lib.mdDoc "Enable the default search provider.";
61 defaultSearchProviderSearchURL = mkOption {
62 type = types.nullOr types.str;
63 description = lib.mdDoc "Chromium default search provider url.";
66 "https://encrypted.google.com/search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}ie={inputEncoding}";
69 defaultSearchProviderSuggestURL = mkOption {
70 type = types.nullOr types.str;
71 description = lib.mdDoc "Chromium default search provider url for suggestions.";
74 "https://encrypted.google.com/complete/search?output=chrome&q={searchTerms}";
77 extraOpts = mkOption {
79 description = lib.mdDoc ''
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 = literalExpression ''
89 "SyncDisabled" = true;
90 "PasswordManagerEnabled" = false;
91 "SpellcheckEnabled" = true;
92 "SpellcheckLanguage" = [
102 ###### implementation
104 config = lib.mkIf cfg.enable {
106 environment.etc."chromium/policies/managed/default.json".text = builtins.toJSON defaultProfile;
107 environment.etc."chromium/policies/managed/extra.json".text = builtins.toJSON cfg.extraOpts;
108 # for google-chrome https://www.chromium.org/administrators/linux-quick-start
109 environment.etc."opt/chrome/policies/managed/default.json".text = builtins.toJSON defaultProfile;
110 environment.etc."opt/chrome/policies/managed/extra.json".text = builtins.toJSON cfg.extraOpts;
112 environment.etc."brave/policies/managed/default.json".text = builtins.toJSON defaultProfile;
113 environment.etc."brave/policies/managed/extra.json".text = builtins.toJSON cfg.extraOpts;