diff options
author | Yuri Nesterov <yuriy.nesterov@unikie.com> | 2024-03-04 14:39:04 +0200 |
---|---|---|
committer | Yuri Nesterov <yuriy.nesterov@unikie.com> | 2024-03-06 21:32:18 +0200 |
commit | 960f93fd4fdb7f2f2140f40edd7dd4a42da65713 (patch) | |
tree | ed249ad1be3bb02399107e61c1978167f2aa6ef5 | |
parent | 2f7fc27d4618c84cc45f706606eedfbf28d7218b (diff) | |
download | nixlib-960f93fd4fdb7f2f2140f40edd7dd4a42da65713.tar nixlib-960f93fd4fdb7f2f2140f40edd7dd4a42da65713.tar.gz nixlib-960f93fd4fdb7f2f2140f40edd7dd4a42da65713.tar.bz2 nixlib-960f93fd4fdb7f2f2140f40edd7dd4a42da65713.tar.lz nixlib-960f93fd4fdb7f2f2140f40edd7dd4a42da65713.tar.xz nixlib-960f93fd4fdb7f2f2140f40edd7dd4a42da65713.tar.zst nixlib-960f93fd4fdb7f2f2140f40edd7dd4a42da65713.zip |
nixos/chromium: add the ability to set initial preferences
3 files changed, 41 insertions, 0 deletions
diff --git a/nixos/modules/programs/chromium.nix b/nixos/modules/programs/chromium.nix index 45a9e9e2a689..5e8983730048 100644 --- a/nixos/modules/programs/chromium.nix +++ b/nixos/modules/programs/chromium.nix @@ -98,6 +98,24 @@ in } ''; }; + + initialPrefs = mkOption { + type = types.attrs; + description = lib.mdDoc '' + Initial preferences are used to configure the browser for the first run. + Unlike {option}`programs.chromium.extraOpts`, initialPrefs can be changed by users in the browser settings. + More information can be found in the Chromium documentation: + <https://www.chromium.org/administrators/configuring-other-preferences/> + ''; + default = {}; + example = literalExpression '' + { + "first_run_tabs" = [ + "https://nixos.org/" + ]; + } + ''; + }; }; }; @@ -110,6 +128,7 @@ in { source = "${cfg.plasmaBrowserIntegrationPackage}/etc/chromium/native-messaging-hosts/org.kde.plasma.browser_integration.json"; }; "chromium/policies/managed/default.json" = lib.mkIf (defaultProfile != {}) { text = builtins.toJSON defaultProfile; }; "chromium/policies/managed/extra.json" = lib.mkIf (cfg.extraOpts != {}) { text = builtins.toJSON cfg.extraOpts; }; + "chromium/initial_preferences" = lib.mkIf (cfg.initialPrefs != {}) { text = builtins.toJSON cfg.initialPrefs; }; # for google-chrome https://www.chromium.org/administrators/linux-quick-start "opt/chrome/native-messaging-hosts/org.kde.plasma.browser_integration.json" = lib.mkIf cfg.enablePlasmaBrowserIntegration { source = "${cfg.plasmaBrowserIntegrationPackage}/etc/opt/chrome/native-messaging-hosts/org.kde.plasma.browser_integration.json"; }; diff --git a/pkgs/applications/networking/browsers/chromium/common.nix b/pkgs/applications/networking/browsers/chromium/common.nix index f3303548e4e0..4bd6e358fdf6 100644 --- a/pkgs/applications/networking/browsers/chromium/common.nix +++ b/pkgs/applications/networking/browsers/chromium/common.nix @@ -216,6 +216,9 @@ let # (we currently package 1.26 in Nixpkgs while Chromium bundles 1.21): # Source: https://bugs.chromium.org/p/angleproject/issues/detail?id=7582#c1 ./patches/angle-wayland-include-protocol.patch + # Chromium reads initial_preferences from its own executable directory + # This patch modifies it to read /etc/chromium/initial_preferences + ./patches/chromium-initial-prefs.patch ] ++ lib.optionals (chromiumVersionAtLeast "120") [ # We need to revert this patch to build M120+ with LLVM 17: ./patches/chromium-120-llvm-17.patch diff --git a/pkgs/applications/networking/browsers/chromium/patches/chromium-initial-prefs.patch b/pkgs/applications/networking/browsers/chromium/patches/chromium-initial-prefs.patch new file mode 100644 index 000000000000..cf359431b43c --- /dev/null +++ b/pkgs/applications/networking/browsers/chromium/patches/chromium-initial-prefs.patch @@ -0,0 +1,19 @@ +diff --git a/chrome/browser/first_run/first_run_internal_linux.cc b/chrome/browser/first_run/first_run_internal_linux.cc +index 33fd579012..9a17b54b37 100644 +--- a/chrome/browser/first_run/first_run_internal_linux.cc ++++ b/chrome/browser/first_run/first_run_internal_linux.cc +@@ -19,13 +19,7 @@ bool IsOrganicFirstRun() { + } + + base::FilePath InitialPrefsPath() { +- // The standard location of the initial prefs is next to the chrome binary. +- base::FilePath dir_exe; +- if (!base::PathService::Get(base::DIR_EXE, &dir_exe)) { +- return base::FilePath(); +- } +- +- return installer::InitialPreferences::Path(dir_exe); ++ return base::FilePath("/etc/chromium/initial_preferences"); + } + + } // namespace internal |