homebrew: add envHints, analytics, and updateReportNew options

Add options to control Homebrew environment variable hints, analytics
notices, and new formulae/casks reports during system activation and
manual brew commands.

These follow the existing autoUpdate pattern: boolean options that
default to true (preserving current behavior) and set the corresponding
HOMEBREW_NO_* environment variable when disabled.

onActivation options affect brew bundle during darwin-rebuild switch.
global options affect interactive brew commands via environment.variables.
This commit is contained in:
mmenanno 2026-04-06 19:20:06 -04:00
parent 06648f4902
commit 8f6396c0dc
No known key found for this signature in database

View file

@ -142,6 +142,43 @@ let
activation.
'';
};
envHints = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Homebrew to print environment variable hints (e.g.,
"Hide these hints with HOMEBREW_NO_ENV_HINTS") during {command}`nix-darwin` system
activation.
Implementation note: when disabled, this option sets the `HOMEBREW_NO_ENV_HINTS`
environment variable when {command}`nix-darwin` invokes {command}`brew bundle [install]`
during system activation.
'';
};
analytics = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Homebrew to print analytics notices and collect anonymous analytics
during {command}`nix-darwin` system activation.
Implementation note: when disabled, this option sets the `HOMEBREW_NO_ANALYTICS`
environment variable when {command}`nix-darwin` invokes {command}`brew bundle [install]`
during system activation.
'';
};
updateReportNew = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Homebrew to print lists of new formulae and casks after auto-updating
during {command}`nix-darwin` system activation.
Implementation note: when disabled, this option sets the
`HOMEBREW_NO_UPDATE_REPORT_NEW` environment variable when {command}`nix-darwin` invokes
{command}`brew bundle [install]` during system activation.
'';
};
extraFlags = mkOption {
type = types.listOf types.str;
default = [ ];
@ -158,6 +195,9 @@ let
config = {
brewBundleCmd = concatStringsSep " " (
optional (!config.autoUpdate) "HOMEBREW_NO_AUTO_UPDATE=1"
++ optional (!config.envHints) "HOMEBREW_NO_ENV_HINTS=1"
++ optional (!config.analytics) "HOMEBREW_NO_ANALYTICS=1"
++ optional (!config.updateReportNew) "HOMEBREW_NO_UPDATE_REPORT_NEW=1"
++ [ "brew bundle --file='${brewfileFile}'" ]
++ optional (!config.upgrade) "--no-upgrade"
++ optional (config.cleanup == "uninstall") "--cleanup"
@ -204,6 +244,42 @@ let
[](#opt-environment.variables).
'';
};
envHints = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Homebrew to print environment variable hints (e.g.,
"Hide these hints with HOMEBREW_NO_ENV_HINTS") when you manually invoke Homebrew commands.
Implementation note: when disabled, this option sets the
`HOMEBREW_NO_ENV_HINTS` environment variable, by adding it to
[](#opt-environment.variables).
'';
};
analytics = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Homebrew to print analytics notices and collect anonymous analytics
when you manually invoke Homebrew commands.
Implementation note: when disabled, this option sets the
`HOMEBREW_NO_ANALYTICS` environment variable, by adding it to
[](#opt-environment.variables).
'';
};
updateReportNew = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable Homebrew to print lists of new formulae and casks after auto-updating
when you manually invoke Homebrew commands.
Implementation note: when disabled, this option sets the
`HOMEBREW_NO_UPDATE_REPORT_NEW` environment variable, by adding it to
[](#opt-environment.variables).
'';
};
# `noLock` was the original option; `lockfiles` replaced it (with inverted semantics).
# Both are now dead: Homebrew Bundle removed lockfile support in Homebrew 4.4.0
# (Oct 2024), so the `HOMEBREW_BUNDLE_NO_LOCK` env var and `--no-lock` CLI flag are
@ -220,6 +296,9 @@ let
homebrewEnvironmentVariables = {
HOMEBREW_BUNDLE_FILE = mkIf config.brewfile "${brewfileFile}";
HOMEBREW_NO_AUTO_UPDATE = mkIf (!config.autoUpdate) "1";
HOMEBREW_NO_ENV_HINTS = mkIf (!config.envHints) "1";
HOMEBREW_NO_ANALYTICS = mkIf (!config.analytics) "1";
HOMEBREW_NO_UPDATE_REPORT_NEW = mkIf (!config.updateReportNew) "1";
};
};
};