nix-darwin icon indicating copy to clipboard operation
nix-darwin copied to clipboard

homebrew.enable fails silently when homebrew is not installed

Open dstcruz opened this issue 11 months ago • 3 comments

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

dstcruz avatar Sep 13 '23 20:09 dstcruz

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 👍

Enzime avatar Sep 14 '23 08:09 Enzime

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.

dstcruz avatar Sep 14 '23 19:09 dstcruz

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

Enzime avatar Sep 14 '23 19:09 Enzime