summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMalo Bourgon <mbourgon@gmail.com>2020-12-30 16:42:31 -0800
committerMalo Bourgon <mbourgon@gmail.com>2020-12-30 19:01:22 -0800
commit2a0b9a9f60a3d3eaca57492f1a8d66082da370ea (patch)
treeb4d98cdcbfc7f7e2bac633f242639f7204d34ce8 /modules
parentc61d6591602b14105a779ad4f695f37437c49468 (diff)
Add options back in for setting global Homebrew variables
Diffstat (limited to 'modules')
-rw-r--r--modules/homebrew.nix43
1 files changed, 32 insertions, 11 deletions
diff --git a/modules/homebrew.nix b/modules/homebrew.nix
index ac89cf6..5088f3c 100644
--- a/modules/homebrew.nix
+++ b/modules/homebrew.nix
@@ -38,13 +38,6 @@ in
configuring your Brewfile, and installing/updating the formulas therein via
the <command>brew bundle</command> command, using <command>nix-darwin</command>.
- When enabled, the <literal>HOMEBREW_BUNDLE_FILE</literal> and
- <literal>HOMEBREW_BUNDLE_NO_LOCK</literal> environment variables are added to
- <option>environment.variables</option>, so that when if/when you run
- <command>brew bundle</command> yourself, it will reference the Brewfile generated by this
- module in the store by default, and skip generating a lockfile (which would fail, since
- lockfiles are generated in the same directory as the Brewfile).
-
Note that enabling this option does not install Homebrew. See the Homebrew website for
installation instructions: https://brew.sh
'';
@@ -87,6 +80,34 @@ in
'';
};
+ global.brewfile = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ When enabled, when you manually invoke <command>brew bundle</command>, it will
+ automatically use the Brewfile in the Nix store that this module generates.
+
+ Sets the <literal>HOMEBREW_BUNDLE_FILE</literal> environment variable to the path of the
+ Brewfile in the Nix store that this module generates, by adding it to
+ <option>environment.variables</option>.
+ '';
+ };
+
+ global.noLock = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ When enabled, lockfiles aren't generated when you manually invoke
+ <command>brew bundle [install]</command>. This is often desirable when
+ <option>homebrew.global.brewfile</option> is enabled, since
+ <command>brew bundle [install]</command> will try to write the lockfile in the Nix store,
+ and complain that it can't (though the command will run successfully regardless).
+
+ Sets the <literal>HOMEBREW_BUNDLE_NO_LOCK</literal> environment variable, by adding it to
+ <option>environment.variables</option>.
+ '';
+ };
+
taps = mkOption {
type = with types; listOf str;
default = [];
@@ -175,10 +196,10 @@ in
optional (cfg.masApps != {}) "mas" ++
optional (cfg.whalebrews != []) "whalebrew";
- environment.variables = mkIf cfg.enable {
- HOMEBREW_BUNDLE_FILE = "${brewfile}";
- HOMEBREW_BUNDLE_NO_LOCK = "1";
- };
+ environment.variables = mkIf cfg.enable (
+ optionalAttrs cfg.global.brewfile { HOMEBREW_BUNDLE_FILE = "${brewfile}"; } //
+ optionalAttrs cfg.global.noLock { HOMEBREW_BUNDLE_NO_LOCK = "1"; }
+ );
system.activationScripts.homebrew.text = mkIf cfg.enable ''
# Homebrew Bundle