From 8f6396c0dc1cc65ed83a73513aefc5e8de33a405 Mon Sep 17 00:00:00 2001 From: mmenanno <1358708+mmenanno@users.noreply.github.com> Date: Mon, 6 Apr 2026 19:20:06 -0400 Subject: [PATCH 1/2] 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. --- modules/homebrew.nix | 79 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/modules/homebrew.nix b/modules/homebrew.nix index 10047b0..aa75f02 100644 --- a/modules/homebrew.nix +++ b/modules/homebrew.nix @@ -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"; }; }; }; From 3510d049d3aba0660c9563a8aace3946ba61501c Mon Sep 17 00:00:00 2001 From: mmenanno <1358708+mmenanno@users.noreply.github.com> Date: Tue, 14 Apr 2026 12:31:00 -0500 Subject: [PATCH 2/2] homebrew: replace envHints/analytics/updateReportNew with onActivation.extraEnv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per review feedback on #1745: rather than adding one boolean option per HOMEBREW_NO_* env var, expose a generic onActivation.extraEnv attrset that is prepended to brewBundleCmd alongside HOMEBREW_NO_AUTO_UPDATE=1. This covers the same use case and the long tail of other HOMEBREW_NO_* vars without tying the module to Homebrew's naming choices. The global-scope booleans are dropped with no replacement — users who want these variables set globally can write them directly into environment.variables, so a global.extraEnv would be pure sugar. --- modules/homebrew.nix | 92 ++++++++------------------------------------ 1 file changed, 17 insertions(+), 75 deletions(-) diff --git a/modules/homebrew.nix b/modules/homebrew.nix index aa75f02..4c5ab98 100644 --- a/modules/homebrew.nix +++ b/modules/homebrew.nix @@ -142,41 +142,24 @@ let activation. ''; }; - envHints = mkOption { - type = types.bool; - default = true; + extraEnv = mkOption { + type = types.attrsOf types.str; + default = { }; + example = { + HOMEBREW_NO_ENV_HINTS = "1"; + HOMEBREW_NO_ANALYTICS = "1"; + }; 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 + Extra environment variables to set when {command}`nix-darwin` invokes {command}`brew bundle [install]` during system activation. + + Useful for setting Homebrew's `HOMEBREW_NO_*` variables (e.g., + `HOMEBREW_NO_ENV_HINTS`, `HOMEBREW_NO_ANALYTICS`, `HOMEBREW_NO_UPDATE_REPORT_NEW`) + that aren't inherited from the user's shell environment because activation runs + under sudo. + + Each entry is prepended to the {command}`brew bundle` invocation in the form + `KEY=VALUE`, alongside `HOMEBREW_NO_AUTO_UPDATE=1` when applicable. ''; }; extraFlags = mkOption { @@ -195,9 +178,7 @@ 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" + ++ mapAttrsToList (k: v: "${k}=${escapeShellArg v}") config.extraEnv ++ [ "brew bundle --file='${brewfileFile}'" ] ++ optional (!config.upgrade) "--no-upgrade" ++ optional (config.cleanup == "uninstall") "--cleanup" @@ -244,42 +225,6 @@ 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 @@ -296,9 +241,6 @@ 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"; }; }; };