zhaofengli / nix-homebrew

Homebrew installation manager for nix-darwin
MIT License
277 stars 13 forks source link

/usr/local/bin is not writeable by nix-homebrew.user after install #3

Open Cu3PO42 opened 1 year ago

Cu3PO42 commented 1 year ago

I've installed Homebrew on a fresh macOS x64 VM. Installing a formulae immediately fails because /usr/local/bin is not writeable by my user. Indeed, it is owned by root, even though most other files in in /usr/local are owned by myuser:admin. The bin and Homebrew folders, however are owned by root:wheel.

I could fix this by inserting an appropriate chown in the setup script, but I'm not 100% sure if that is just a band-aid without fixing the underlying root cause.

Unfortunately I don't currently have access to an aarch64 Mac to test the behaviour there.

Cu3PO42 commented 1 year ago

I started looking into this, but have not been able to pinpoint the issue. Here's what I know:

I currently cannot explain the inconsisties I've observed.

Cu3PO42 commented 1 year ago

Thanks for looking into this! Right now I have a serviceable hot fix for this: I added

  system.activationScripts.extraUserActivation.text = lib.mkOrder 1501 (lib.concatStringsSep "\n" (lib.mapAttrsToList (prefix: d: if d.enable then ''
    sudo chown -R ${config.nix-homebrew.user} ${prefix}/bin
    sudo chgrp -R ${config.nix-homebrew.group} ${prefix}/bin
  '' else "") config.nix-homebrew.prefixes));

to my config, which allows the installation to proceed successfully.