at 22.05-pre 4.0 kB view raw
1{ config, lib, ... }: 2 3with lib; 4 5let 6 cfg = config.programs.chromium; 7 8 defaultProfile = filterAttrs (k: v: v != null) { 9 HomepageLocation = cfg.homepageLocation; 10 DefaultSearchProviderSearchURL = cfg.defaultSearchProviderSearchURL; 11 DefaultSearchProviderSuggestURL = cfg.defaultSearchProviderSuggestURL; 12 ExtensionInstallForcelist = cfg.extensions; 13 }; 14in 15 16{ 17 ###### interface 18 19 options = { 20 programs.chromium = { 21 enable = mkEnableOption "<command>chromium</command> policies"; 22 23 extensions = mkOption { 24 type = types.listOf types.str; 25 description = '' 26 List of chromium extensions to install. 27 For list of plugins ids see id in url of extensions on 28 <link xlink:href="https://chrome.google.com/webstore/category/extensions">chrome web store</link> 29 page. To install a chromium extension not included in the chrome web 30 store, append to the extension id a semicolon ";" followed by a URL 31 pointing to an Update Manifest XML file. See 32 <link xlink:href="https://cloud.google.com/docs/chrome-enterprise/policies/?policy=ExtensionInstallForcelist">ExtensionInstallForcelist</link> 33 for additional details. 34 ''; 35 default = []; 36 example = literalExpression '' 37 [ 38 "chlffgpmiacpedhhbkiomidkjlcfhogd" # pushbullet 39 "mbniclmhobmnbdlbpiphghaielnnpgdp" # lightshot 40 "gcbommkclmclpchllfjekcdonpmejbdp" # https everywhere 41 "cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin 42 ] 43 ''; 44 }; 45 46 homepageLocation = mkOption { 47 type = types.nullOr types.str; 48 description = "Chromium default homepage"; 49 default = null; 50 example = "https://nixos.org"; 51 }; 52 53 defaultSearchProviderSearchURL = mkOption { 54 type = types.nullOr types.str; 55 description = "Chromium default search provider url."; 56 default = null; 57 example = 58 "https://encrypted.google.com/search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}ie={inputEncoding}"; 59 }; 60 61 defaultSearchProviderSuggestURL = mkOption { 62 type = types.nullOr types.str; 63 description = "Chromium default search provider url for suggestions."; 64 default = null; 65 example = 66 "https://encrypted.google.com/complete/search?output=chrome&q={searchTerms}"; 67 }; 68 69 extraOpts = mkOption { 70 type = types.attrs; 71 description = '' 72 Extra chromium policy options. A list of available policies 73 can be found in the Chrome Enterprise documentation: 74 <link xlink:href="https://cloud.google.com/docs/chrome-enterprise/policies/">https://cloud.google.com/docs/chrome-enterprise/policies/</link> 75 Make sure the selected policy is supported on Linux and your browser version. 76 ''; 77 default = {}; 78 example = literalExpression '' 79 { 80 "BrowserSignin" = 0; 81 "SyncDisabled" = true; 82 "PasswordManagerEnabled" = false; 83 "SpellcheckEnabled" = true; 84 "SpellcheckLanguage" = [ 85 "de" 86 "en-US" 87 ]; 88 } 89 ''; 90 }; 91 }; 92 }; 93 94 ###### implementation 95 96 config = lib.mkIf cfg.enable { 97 # for chromium 98 environment.etc."chromium/policies/managed/default.json".text = builtins.toJSON defaultProfile; 99 environment.etc."chromium/policies/managed/extra.json".text = builtins.toJSON cfg.extraOpts; 100 # for google-chrome https://www.chromium.org/administrators/linux-quick-start 101 environment.etc."opt/chrome/policies/managed/default.json".text = builtins.toJSON defaultProfile; 102 environment.etc."opt/chrome/policies/managed/extra.json".text = builtins.toJSON cfg.extraOpts; 103 }; 104}