nix-darwin
nix-darwin copied to clipboard
homebrew.enable fails silently when homebrew is not installed
Description:
Running darwin-rebuild switch --flake .#my-machine with a flake that has homebrew.enable = true; completes without a warning or an error.
Expectation:
I would expect to at least be warned that homebrew is not installed, instead of failing silently.
Version:
> darwin-version
23.11pre-git+darwin4.4496ab2
I believe the issue is that there is no exit 1 here:
https://github.com/LnL7/nix-darwin/blob/master/modules/homebrew.nix#L791
I'll be busy for a while, so if you could make a PR that would be appreciated 👍
On retrying this, I see that the error is actually printed:
...
user defaults...
setting up user launchd services...
Homebrew bundle...
error: Homebrew is not installed, skipping...
setting up /Applications/Nix Apps...
setting up pam...
applying patches...
setting up /etc...
...
Do we think that's sufficient? Or should we exit 1 to fail the build? I'm happy to provide the PR if we think we should fail.
I definitely think we should fail, however to prevent a partial system activation, instead of adding exit 1 to Homebrew's activation script, we can move the logic to check if Homebrew is installed to the checks activation script using the following option:
https://github.com/LnL7/nix-darwin/blob/4496ab26628c5f43d2a5c577a06683c753e32fe2/modules/system/checks.nix#L216-L219