zhaofengli / nix-homebrew

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

Homebrew installation succeeded but executing brew resulting in error #24

Closed itaywol closed 6 months ago

itaywol commented 6 months ago

Hey, I am able to "install" brew successfully through this package as flake input, but for some reason when trying to use nix-darwin option homebrew.enable = true when it tries to run homebrew on activation it gets an ruby error which seems like access issue.

flake inputs:

 inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
    nixpks-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager/release-23.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nix-darwin.url = "github:LnL7/nix-darwin";
    nix-darwin.inputs.nixpkgs.follows = "nixpkgs";

    nix-homebrew = {
      url = "github:zhaofengli-wip/nix-homebrew";
    };
    homebrew-bundle = { // Removed the usage of it just to understand the cause of the issue
      url = "github:homebrew/homebrew-bundle";
      flake = false;
    };
    homebrew-core = {
      url = "github:homebrew/homebrew-core";
      flake = false;
    };
    homebrew-cask = {
      url = "github:homebrew/homebrew-cask";
      flake = false;
    }; 
  };

darwin configurations:

let macUser = "xxx"; 
....
darwinConfigurations."xxxxxx" =
        nix-darwin.lib.darwinSystem {
        system = "aarch64-darwin";
            specialArgs = { inherit self inputs outputs macUser;};
            modules = [ 
          home-manager.darwinModules.home-manager {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.extraSpecialArgs = {inherit inputs outputs macUser self;};
          }
          nix-homebrew.darwinModules.nix-homebrew
          {
            nix-homebrew = {
              user = macUser;
              enable = true;
              taps = {
                "homebrew/homebrew-core" = homebrew-core;
                "homebrew/homebrew-cask" = homebrew-cask;
              };
              autoMigrate = true;
            };
          }
        ./darwin/xxxxxx/configuration.nix 
        ./modules/darwin/home-manager.nix
        ];
};

Homebrew mentions in home-manager.nix file:

{ config, pkgs, macUser, ... }:
{
  # imports = [
  #  ./dock
  # ];

  # It me
  users.users.${macUser} = {
    name = "${macUser}";
    home = "/Users/${macUser}";
    isHidden = false;
    shell = pkgs.zsh;
  };

  homebrew = {
    enable = true;
  };
}

The error:

setting up Homebrew (/opt/homebrew)...
user defaults...
setting up user launchd services...
Homebrew bundle...
<internal:/nix/store/qlcwc10p05clxbq3hm1r25pj2hpz5q4s-ruby-3.3.0-preview3/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:38:in `require': cannot load such file -- sorbet-runtime (LoadError)
    from <internal:/nix/store/qlcwc10p05clxbq3hm1r25pj2hpz5q4s-ruby-3.3.0-preview3/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:38:in `require'
    from /nix/store/a1lzbyrb3whaxr6ig9pcbj4lz5pxk95c-brew-4.3.1-patched/Library/Homebrew/standalone/sorbet.rb:4:in `<top (required)>'
    from /nix/store/a1lzbyrb3whaxr6ig9pcbj4lz5pxk95c-brew-4.3.1-patched/Library/Homebrew/startup.rb:10:in `require_relative'
    from /nix/store/a1lzbyrb3whaxr6ig9pcbj4lz5pxk95c-brew-4.3.1-patched/Library/Homebrew/startup.rb:10:in `<top (required)>'
    from /nix/store/a1lzbyrb3whaxr6ig9pcbj4lz5pxk95c-brew-4.3.1-patched/Library/Homebrew/global.rb:4:in `require_relative'
    from /nix/store/a1lzbyrb3whaxr6ig9pcbj4lz5pxk95c-brew-4.3.1-patched/Library/Homebrew/global.rb:4:in `<top (required)>'
    from /opt/homebrew/Library/Homebrew/brew.rb:18:in `require_relative'
    from /opt/homebrew/Library/Homebrew/brew.rb:18:in `<main>'
zhaofengli commented 6 months ago

Hi, please upgrade to the latest nixpkgs unstable with a non-preview version of Ruby 3.3 and it should work. We are using the bundled gems and it's indeed a bit fragile.

itaywol commented 6 months ago

Hi, please upgrade to the latest nixpkgs unstable with a non-preview version of Ruby 3.3 and it should work. We are using the bundled gems and it's indeed a bit fragile.

Hi, please upgrade to the latest nixpkgs unstable with a non-preview version of Ruby 3.3 and it should work. We are using the bundled gems and it's indeed a bit fragile.

Yep, that worked. Awesome 🙌

whazor commented 5 months ago

This was also resolved for me by upgrading to nixpkgs 24.05.