zhaofengli / nix-homebrew

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

Brew was not installed Correctly #33

Open darbster145 opened 3 months ago

darbster145 commented 3 months ago

I set up nix-hombrew but it did not install brew under /run/current-system/sw/bin. When I run type brew is says brew is /usr/local/bin/brew not /run/current-system/sw/bin which it is supposed to per the guide. Has anyone ran into this issue? Here is my nix-darwin flake.nix:

`{ description = "Example Darwin system flake";

inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nix-darwin.url = "github:LnL7/nix-darwin"; nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; homebrew-core = { url = "github:homebrew/homebrew-core"; flake = false; }; homebrew-cask = { url = "github:homebrew/homebrew-cask"; flake = false; }; homebrew-bundle = { url = "github:homebrew/homebrew-bundle"; flake = false; }; };

outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, homebrew-core, homebrew-cask, homebrew-bundle, ... }: let configuration = { pkgs, ... }: {

List packages installed in system profile. To search by name, run:

  # $ nix-env -qaP | grep wget
  environment.systemPackages = with pkgs; [
    neovim
    tldr
    zoxide
    fastfetch
    kitty
google-chrome
raycast
darwin.xcode_15_1
   ];

 homebrew = {
   enable = true;
   onActivation.cleanup = "uninstall";

   taps = [];
   brews = [ "cowsay" ];
   casks = [];
   };

  # Auto upgrade nix package and the daemon service.
  services.nix-daemon.enable = true;
  nix.package = pkgs.nix;

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # Necessary for using flakes on this system.
  nix.settings.experimental-features = "nix-command flakes";

  # Create /etc/zshrc that loads the nix-darwin environment.
  programs.zsh.enable = true;  # default shell on catalina
  # programs.fish.enable = true;

  # Set Git commit hash for darwin-version.
  system.configurationRevision = self.rev or self.dirtyRev or null;

  # Used for backwards compatibility, please read the changelog before changing.
  # $ darwin-rebuild changelog
  system.stateVersion = 4;

  # The platform the configuration will be used on.
  nixpkgs.hostPlatform = "aarch64-darwin";

  # Touch ID auth for sudo
  security.pam.enableSudoTouchIdAuth = true;

  system.defaults = {
    dock.autohide = true;
    dock.mru-spaces = false;
    finder.AppleShowAllExtensions = true;
    finder.FXPreferredViewStyle = "clmv";
    loginwindow.LoginwindowText = "sugundezz";
    screencapture.location = "~/Pictures/screenshots";
    screensaver.askForPasswordDelay = 10;
  };

nix-homebrew = {
  enable = true;
  enableRosetta = true;
  user = "Brad";
  autoMigrate = true;
  taps = {
"homebrew/homebrew-core" = homebrew-core;
"homebrew/homebrew-cask" = homebrew-cask;
"homebrew/homebrew-bundle" = homebrew-bundle;
  };
  mutableTaps = false;
};

};

in {

Build darwin flake using:

# $ darwin-rebuild build --flake .#crapple
darwinConfigurations."crapple" = nix-darwin.lib.darwinSystem {
  modules = [ configuration nix-homebrew.darwinModules.nix-homebrew ];
};

# Expose the package set, including overlays, for convenience.
darwinPackages = self.darwinConfigurations."crapple".pkgs;

}; }`

dezren39 commented 1 month ago

did you already have brew installed before this?

dezren39 commented 1 month ago

whoops tagged the wrong issue in #39

nickkadutskyi commented 4 weeks ago

In my case I see multiple links to brew:

❯ whereis -a brew
brew: /opt/homebrew/bin/brew /run/current-system/sw/bin/brew /usr/local/bin/brew

All of them are symlinks to actual binaries in a nix store:

❯ ls -la /opt/homebrew/bin/brew
lrwxr-xr-x  1 root  admin  48 Oct 27 16:45 /opt/homebrew/bin/brew -> /nix/store/smpkqmn0hh0vz5km45n52ccxm4v2isjx-brew
❯ ls -la /usr/local/bin/brew
lrwxr-xr-x  1 root  wheel  48 Oct 27 16:45 /usr/local/bin/brew -> /nix/store/jayrc1v4g1jfyl4d97v1pbc3744crp0r-brew
❯ ls -la /run/current-system/sw/bin/brew
lrwxr-xr-x  1 root  wheel  57 Dec 31  1969 /run/current-system/sw/bin/brew -> /nix/store/h0b3sjlfgca3khm2fif0gncb8bffb65k-brew/bin/brew

/run/current-system/sw/bin/brew this one is basically a script which checks whether I am on apple silicon and picks one of the other two paths appropriate for my system.