nix-darwin
nix-darwin copied to clipboard
homebrew: default `brewPrefix` should point to the default value of `$(brew --prefix)` not `$(brew --prefix)/bin`
The brewPrefix
value defaults to /opt/homebrew/bin
or /usr/local/bin
, which is a bit misleading considering that the "prefix" should refer to the next level up (/opt/homebrew
or /usr/local
), which also happens to align with the output of brew --prefix
.
This confusing terminology has bitten me a couple times when setting environment.systemPath = ["${config.homebrew.brewPrefix}/bin"]
, which results in the unexpected (and potentially shell-breaking) value of /opt/homebrew/bin/bin
added to $PATH
. Also, side note: shouldn't that value be added to $PATH
automatically if config.homebrew.enable == true
(or at least make that an option)?
From brew(1):
--prefix
[--unbrewed
] [--installed
] [formula
…]Display Homebrew’s install path. Default:
- macOS Intel:
/usr/local
- macOS ARM:
/opt/homebrew
- Linux:
/home/linuxbrew/.linuxbrew
And from GNU Autoconf documentation:
By default,
configure
sets the prefix for files it installs to /usr/local.
Also see:
Also, for reference, here's the output of brew shellenv
on my aarch64-darwin
system:
❯ brew shellenv
export HOMEBREW_PREFIX="/opt/homebrew";
export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
export HOMEBREW_REPOSITORY="/opt/homebrew";
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";
@malob any thoughts on this issue? I'm not too familiar as I don't personally use brew
I think this would be reasonable but it would be a breaking change that we'd have to handle or warn about somehow. (Error out when the prefix ends with /bin
?)
I just realized the "fix" I committed in my personal config (visible in history above) results in a $MANPATH
that does not include anything managed by Nix.
I hadn't noticed until I couldn't find an rsync
option that I know exists but was not found in its manpage. While rsync --version
says 3.2.7, turns out that the manpage I get from man rsync
is for rsync
@2.6.9 (the version included in macOS).
@montchr This issue goes beyond nix-darwin (I haven't yet installed nix-darwin), but I brought this up in the nix installer here https://github.com/DeterminateSystems/nix-installer/issues/715 (not sure if that was the right place).