Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homebrew.onActivation.cleanup: option to fail activation as part of checks #1032

Open
ian-h-chamberlain opened this issue Aug 7, 2024 · 0 comments

Comments

@ian-h-chamberlain
Copy link
Contributor

With Homebrew/homebrew-bundle#1418 there is now an easy command available to check if any brews, casks, vscodes would be removed by --cleanup. I was thinking about adding another option for homebrew.onActivation.cleanup (perhaps "check"?), which simply fails the pre-activation checks if the system is not in sync with the generated Brewfile (could also be used with darwin-rebuild check without actually performing uninstalls). For now I have something like this in my own config, but thought it seemed like it might be useful enough to upstream; it also relies on some internal options to work:

{ pkgs, config, ... }:
let
  brewfileFile = pkgs.writeText "Brewfile" config.homebrew.brewfile;
in
{
  system.checks.text = ''
    PATH="${config.homebrew.brewPrefix}":$PATH brew bundle cleanup --file='${brewfileFile}' --no-lock
  '';
}

Would a PR adding this as a first-class option be accepted? If so, I wasn't sure whether it should be another choice for onActivation.cleanup, or a separate option like homebrew.onActivation.checkCleanup. I could see wanting something like this, but I'm not sure if there's any precedent for options like this that have different outcomes during check vs switch:

{
	homebrew.onActivation = {
		checkCleanup = true; # only fails `darwin-rebuild check`
		cleanup = "zap"; # invokes --zap on `darwin-rebuild switch`
	};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant