From 9ccc82c1ccc241d2b9eeded8033a4baa204ed959 Mon Sep 17 00:00:00 2001 From: Bo Jeanes Date: Fri, 19 Jul 2024 16:01:54 +1000 Subject: [PATCH] Move brew path into home.sessionVariables Also, instead of checking for both directories each time, just do an architecture check during build and add the path blindly. --- flake.nix | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index 5acf842..05affa3 100644 --- a/flake.nix +++ b/flake.nix @@ -339,24 +339,22 @@ linux = { }; # home-manager config specific to Darwin - darwin = let - addBrewPath = '' - # Apple Silicon - [ -d /opt/homebrew/bin ] && export PATH="/opt/homebrew/bin:$PATH" - [ -d /opt/homebrew/sbin ] && export PATH="/opt/homebrew/sbin:$PATH" - - # Intel - [ -d /usr/local/bin ] && export PATH="/usr/local/bin:$PATH" - [ -d /usr/local/sbin ] && export PATH="/usr/local/sbin:$PATH" - ''; - in { + darwin = { pkgs, ... }: { # Yank/paste in Neovim to/from macOS clipboard by default programs.nixvim.clipboard.register = "unnamedplus"; programs.git.extraConfig."gpg \"ssh\"".program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"; - programs.bash.initExtra = addBrewPath; - programs.zsh.initExtra = addBrewPath; + home.sessionVariables = + let + brewPrefix = + if pkgs.stdenv.hostPlatform.isAarch64 + then "/opt/homebrew" + else "/usr/local"; + in + { + PATH = "${brewPrefix}/bin:${brewPrefix}/sbin:$PATH"; + }; }; }; };