zhaofengli / nix-homebrew

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

source fullpaths based on homebrew install location #27

Open aspauldingcode opened 5 months ago

aspauldingcode commented 5 months ago

I want to source a homebrew package. On m1, it's in /opt/homebrew/bin on intel, it's in /usr/local/bin

The problem is in my config files. If I run a let in syntax like: brewpackage1 = "/opt/homebrew/bin"; #fullpath of package

I can use this fullpath to fix all my bash scripts configurations (fixes a lot of functionality for me) However, since I'm on m1, this is fine. It is not fine when I switch machines and use the same config. Is there something like a $homebrew-path to rely on? So I could instead do: brewpackage1 = "/$homebrew-path/bin"; # like this?

This way, I could share the config without having to define two separate brew locations per machine

aspauldingcode commented 5 months ago

I do like this:

{
  pkgs,
  config,
  lib,
  ...
}:
# NIXY-specific packages

let
  jq = "/run/current-system/sw/bin/jq";
  yabai = "/opt/homebrew/bin/yabai";
  sketchybar = "/opt/homebrew/bin/sketchybar";
  borders = "${config.home.homeDirectory}/Downloads/JankyBorders-main/bin/borders"; # master contains apply-to=<window-id> so use this for now.
  #borders = "/opt/homebrew/bin/borders"; # should be this.
  inherit (config.colorScheme) colors;
in
{

But I know it won't work on intel homebrew. How can I update these?

aspauldingcode commented 5 months ago

I've written an updated way but it could still break if homebrew decided to change these fullpaths for either.

let
  systemType = pkgs.stdenv.hostPlatform.system;
  homebrewPath = if systemType == "aarch64-darwin" then "/opt/homebrew/bin" else if systemType == "x86_64-darwin" then "/usr/local/bin" else throw "Homebrew Unsupported architecture: ${systemType}";
  jq = "/run/current-system/sw/bin/jq";
  yabai = "${homebrewPath}/yabai";
  sketchybar = "${homebrewPath}/sketchybar";
  borders = "${homebrewPath}/borders";
  inherit (config.colorScheme) colors;
in