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

Add taps : Permission denied / exited with 128 #125

Open
HugoHeneault opened this issue Nov 15, 2024 · 2 comments
Open

Add taps : Permission denied / exited with 128 #125

HugoHeneault opened this issue Nov 15, 2024 · 2 comments

Comments

@HugoHeneault
Copy link

Hi there,

First thanks for that great repo which was a nice introduction to nix to me.

I'm trying to add taps to my setup.
I read #66, and I already did as stated as a solution:

  homebrew = {
    enable = true;
+    taps = ["leoafarias/homebrew-fvm"];
+
+    brews = [
+      "leoafarias/homebrew-fvm"
+    ];

    casks = pkgs.callPackage ./casks.nix {};

But when nix run .#build-switch

It returns

Homebrew bundle...
Tapping leoafarias/fvm
==> Tapping leoafarias/fvm
fatal: could not create leading directories of '/opt/homebrew/Library/Taps/leoafarias/homebrew-fvm': Permission denied
Error: Failure while executing; `git clone https://github.com/leoafarias/homebrew-fvm /opt/homebrew/Library/Taps/leoafarias/homebrew-fvm --origin=origin --template= --config core.fsmonitor=false` exited with 128.
Tapping leoafarias/fvm has failed!
Installing leoafarias/homebrew-fvm
Warning: 'leoafarias/homebrew-fvm' formula is unreadable: No available formula with the name "homebrew-fvm".
Warning: No available formula with the name "homebrew-fvm".
Error: No formulae found for homebrew-fvm.
==> Searching for similarly named formulae...
Installing leoafarias/homebrew-fvm has failed!

Running brew tap leoafarias/fvm returns the same error message :

brew tap leoafarias/fvm                        

==> Tapping leoafarias/fvm
fatal: could not create leading directories of '/opt/homebrew/Library/Taps/leoafarias/homebrew-fvm': Permission denied
Error: Failure while executing; `git clone https://github.com/leoafarias/homebrew-fvm /opt/homebrew/Library/Taps/leoafarias/homebrew-fvm --origin=origin --template= --config core.fsmonitor=false` exited with 128.

I can't figure out what's wrong with my setup. Thank you for your help 🙏

@HugoHeneault HugoHeneault changed the title Add taps Add taps : Permission denied / exited with 128 Nov 15, 2024
@dustinlyons
Copy link
Owner

Can you run

ls -l /opt/homebrew

Is this owner by your user? Here is the dependency we use, nix-homebrew, I know they "migrate" existing configurations but maybe something went wrong.

You could also try to set this option to false (I think maybe this is default now, but something you could try regardless)

  homebrew = {
    enable = true;
    global.lockfiles = false;
  };

Otherwise I'm not exactly sure as I personally don't use taps. You can also just keep homebrew out of the configuration entirely, and have a traditional Brewfile sit next to this configuration. Just something to consider. This would enable just removing those lines from the home-manager.nix configuration file, something to unblock you regardless.

@tanshunyuan
Copy link

Hi @HugoHeneault , you can try the following method.

Because we're using nix-homebrew, the homebrew.taps doesn't seem to work. We need to declare the taps as nix-homebrew docs here

flake.nix

{
	# define the taps from leofarias
	inputs = {
		...
	    leoafarias-taps = {
	      url = "github:leoafarias/homebrew-fvm";
	      flake = false;
	    };
		...
	}
};

outputs = {
	leoafarias-taps
} @inputs:
	
	{
      darwinConfigurations = nixpkgs.lib.genAttrs darwinSystems (system: let
        user = "xxx";
      in
        darwin.lib.darwinSystem {
          inherit system;
          specialArgs = inputs;
          modules = [
            ({ config, ...}: {
                homebrew.taps = builtins.attrNames config.nix-homebrew.taps;
            })
            home-manager.darwinModules.home-manager
            nix-homebrew.darwinModules.nix-homebrew
            {
              nix-homebrew = {
                inherit user;
                enable = true;
                enableRosetta = true;
                taps = {
				# Define the tap here as well
                  "leoafarias/homebrew-fvm" = leoafarias-taps;
                };
                mutableTaps = false;
                autoMigrate = true;
              };
            }
          ];
        }
      );
	}

Then in your darwin/home-manager.nix, within the homebrew block do the following

  homebrew = {
    # This is a module from nix-darwin
    # Homebrew is *installed* via the flake input nix-homebrew
    enable = true;
    onActivation = {
        autoUpdate = false;
        upgrade = false;
        cleanup = "zap";
    };
    casks = pkgs.callPackage ./casks.nix {};
    brews = [
       "fvm"
    ];
  };

Save the updated configuration, and run nix run .#build-switch and it'll start installing. Once the process is done, fvm is installed

Screenshot 2024-11-23 at 9 25 58 PM

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

3 participants