dustinlyons / nixos-config

General purpose Nix configuration for macOS / NixOS with starter templates + step-by-step guides ✨
BSD 3-Clause "New" or "Revised" License
1.79k stars 113 forks source link

Permission denied with homebrew #66

Closed bart-sofomo closed 7 months ago

bart-sofomo commented 7 months ago

Hi, I've added two packages:

  "koekeishiya/formulae/yabai"
  "koekeishiya/formulae/skhd"

When running nix run .#build-switch I'm getting:

Installing yabai
==> Tapping koekeishiya/formulae
fatal: could not create leading directories of '/usr/local/Homebrew/Library/Taps/koekeishiya/homebrew-formulae': Permission denied
Error: Failure while executing; `git clone https://github.com/koekeishiya/homebrew-formulae /usr/local/Homebrew/Library/Taps/koekeishiya/homebrew-formulae --origin=origin --template= --config core.fsmonitor=false` exited with 128.
Installing yabai has failed!
Installing skhd
==> Tapping koekeishiya/formulae
fatal: could not create leading directories of '/usr/local/Homebrew/Library/Taps/koekeishiya/homebrew-formulae': Permission denied
Error: Failure while executing; `git clone https://github.com/koekeishiya/homebrew-formulae /usr/local/Homebrew/Library/Taps/koekeishiya/homebrew-formulae --origin=origin --template= --config core.fsmonitor=false` exited with 128.
Installing skhd has failed!

Not sure why this is happening - any idea?

bart-sofomo commented 7 months ago

When I create manually these paths I'm getting then:

Installing yabai
Warning: Cask 'yabai' is unavailable: '/usr/local/Homebrew/Library/Taps/koekeishiya/homebrew-formulae/Casks/yabai.rb' does not exist.
Error: No casks found for yabai.
==> Searching for similarly named casks...
Installing yabai has failed!
Installing skhd
Warning: Cask 'skhd' is unavailable: '/usr/local/Homebrew/Library/Taps/koekeishiya/homebrew-formulae/Casks/skhd.rb' does not exist.
Error: No casks found for skhd.
==> Searching for similarly named casks...
Installing skhd has failed!
bart-sofomo commented 7 months ago

Next steps I've done

  1. Added input:

    koekeishiya-formulae = {
    url = "github:koekeishiya/homebrew-formulae";
    flake = false;
    };
  2. Added in outputs: koekeishiya-formulae

  3. Added to taps:

    "koekeishiya/homebrew-formulae" = koekeishiya-formulae;
  4. Then in casks:

    "koekeishiya/homebrew-formulae/yabai"
    "koekeishiya/homebrew-formulae/skhd"

The problem is that it tried to install:

Installing yabai
Warning: Cask 'yabai' is unavailable: '/usr/local/Homebrew/Library/Taps/koekeishiya/homebrew-formulae/Casks/yabai.rb' does not exist.
Error: No casks found for yabai.
==> Searching for similarly named casks...
Installing yabai has failed!
Installing skhd
Warning: Cask 'skhd' is unavailable: '/usr/local/Homebrew/Library/Taps/koekeishiya/homebrew-formulae/Casks/skhd.rb' does not exist.
Error: No casks found for skhd.
==> Searching for similarly named casks...
Installing skhd has failed!

while it should not have Casks in the path - what am I missing?

dustinlyons commented 7 months ago

This project uses the homebrew options in nix-darwin. They are all here:

https://github.com/dustinlyons/nixos-config/blob/347e50f8e2e469122468a3aa09fc08713d57dfcb/templates/starter/modules/darwin/home-manager.nix#L26

  homebrew = {
    enable = true;
    casks = pkgs.callPackage ./casks.nix {};

    # These app IDs are from using the mas CLI app
    # mas = mac app store
    # https://github.com/mas-cli/mas
    #
    # $ nix shell nixpkgs#mas
    # $ mas search <app name>
    #
    masApps = {
      "1password" = 1333542190;
      "wireguard" = 1451685025;
    };
  };

And then as you found, we just import homebrew using nix-homebrew. That's the extent of the homebrew configuration.

I think your underlying question is: "how do I add my own taps to this configuration?" I would dig around the nix-darwin homebrew option docs for that. Here are some resources:

https://github.com/LnL7/nix-darwin/blob/36524adc31566655f2f4d55ad6b875fb5c1a4083/modules/homebrew.nix#L597

https://daiderd.com/nix-darwin/manual/index.html#opt-homebrew.enable

bart-sofomo commented 7 months ago

@dustinlyons thanks for pointing out the links. At the end it is like add inside hombrew config in home-manager:

 taps = [
      {
        name = "koekeishiya/homebrew-formulae";
        clone_target = "https://github.com/koekeishiya/homebrew-formulae.git";
        force_auto_update = true;
      }
    ];

    brews = [
      "koekeishiya/homebrew-formulae/yabai"
      "koekeishiya/homebrew-formulae/skhd"
    ];