From 6ef4af902bf6f60bfe52f48debf9887a969b252a Mon Sep 17 00:00:00 2001 From: en <54501296+2hexed@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:14:07 +0530 Subject: [PATCH] nixos/brave: system-wide brave module/options --- .../manual/release-notes/rl-2611.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/programs/brave.nix | 67 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 nixos/modules/programs/brave.nix diff --git a/nixos/doc/manual/release-notes/rl-2611.section.md b/nixos/doc/manual/release-notes/rl-2611.section.md index 3a6ecc048aa2..1b0d60966e3c 100644 --- a/nixos/doc/manual/release-notes/rl-2611.section.md +++ b/nixos/doc/manual/release-notes/rl-2611.section.md @@ -29,6 +29,8 @@ +- [Brave](https://brave.com), a Chromium-based web browser. Available as [programs.brave](#opt-programs.brave.enable). Note that if you were previously configuring Brave via [programs.chromium](#opt-programs.chromium.enable), you can only use one of the two modules; using `programs.brave` is recommended. + - Management of `$XDG_*_HOME` environment variables from [XDG Base Directory specification](https://specifications.freedesktop.org/basedir-spec/latest/). Available as [xdg.directories](#opt-xdg.directories.enable). - Enable [Dux Calendar](#opt-programs.dux-calendar.enable): diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 69be155851b4..3393ac3fee98 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -185,6 +185,7 @@ ./programs/bazecor.nix ./programs/bcc.nix ./programs/benchexec.nix + ./programs/brave.nix ./programs/browserpass.nix ./programs/btrfs-heatmap.nix ./programs/calls.nix diff --git a/nixos/modules/programs/brave.nix b/nixos/modules/programs/brave.nix new file mode 100644 index 000000000000..a2d48bbc5fc3 --- /dev/null +++ b/nixos/modules/programs/brave.nix @@ -0,0 +1,67 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.programs.brave; + + defaultProfile = lib.filterAttrs (_: v: v != null) { + ExtensionInstallForcelist = cfg.extensions; + }; + + braveEtcConfig = { + # Managed (enterprise) policy files + "brave/policies/managed/default.json" = lib.mkIf (defaultProfile != { }) { + text = builtins.toJSON defaultProfile; + }; + + "brave/policies/managed/extra.json" = lib.mkIf (cfg.policies != { }) { + text = builtins.toJSON cfg.policies; + }; + }; + +in +{ + options.programs.brave = { + enable = lib.mkEnableOption "the Brave web browser"; + + package = lib.mkPackageOption pkgs "brave" { + default = [ "brave" ]; + }; + + extensions = lib.mkOption { + type = with lib.types; nullOr (listOf str); + default = null; + description = '' + List of Brave (Chromium-style) extensions to force-install. + These work the same way as Chromium extensions: a Chrome Web Store ID, + optionally followed by `;url-to-update-manifest.xml`. + ''; + }; + + policies = lib.mkOption { + type = lib.types.attrs; + default = { }; + description = '' + Additional Brave Enterprise policy settings. + These follow the same format as Chromium policies: + + ''; + example = { + SyncDisabled = true; + MetricsReportingEnabled = false; + BraveRewardsDisabled = false; + }; + }; + }; + + config = lib.mkIf cfg.enable { + environment = { + etc = braveEtcConfig; + systemPackages = [ cfg.package ]; + }; + }; +}