nixos/brave: system-wide brave module/options (#469315)

This commit is contained in:
Pascal Bach
2026-11-15 10:14:03 +00:00
committed by GitHub
3 changed files with 70 additions and 0 deletions

View File

@@ -32,6 +32,8 @@
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
- [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):

View File

@@ -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

View File

@@ -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:
<https://support.brave.app/hc/en-us/articles/360039248271-Group-Policy>
'';
example = {
SyncDisabled = true;
MetricsReportingEnabled = false;
BraveRewardsDisabled = false;
};
};
};
config = lib.mkIf cfg.enable {
environment = {
etc = braveEtcConfig;
systemPackages = [ cfg.package ];
};
};
}