{ config, lib, pkgs, ... }: let inherit (lib) mkIf; caskIsPresent = cask: lib.any (x: x == cask) config.homebrew.casks; mkIfCaskPresent = cask: mkIf (caskIsPresent cask); brewEnabled = config.homebrew.enable; gamesEnabled = config.games.enable; in { # perma-enabling to prevent losing brew when we skip bundling # environment.shellInit = mkIf brewEnabled '' environment.shellInit = '' eval "$(${config.homebrew.brewPrefix}/brew shellenv)" ''; # https://docs.brew.sh/Shell-Completion#configuring-completions-in-fish # For some reason if the Fish completions are added at the end of `fish_complete_path` they don't # seem to work, but they do work if added at the start. # programs.fish.interactiveShellInit = mkIf brewEnabled '' programs.fish.interactiveShellInit = '' if test -d (brew --prefix)"/share/fish/completions" set -p fish_complete_path (brew --prefix)/share/fish/completions end if test -d (brew --prefix)"/share/fish/vendor_completions.d" set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d end ''; homebrew.enable = pkgs.lib.homebrew-enabled; homebrew.onActivation.autoUpdate = true; homebrew.onActivation.upgrade = true; homebrew.onActivation.cleanup = "zap"; homebrew.global.brewfile = true; homebrew.taps = [ "homebrew/cask" "homebrew/cask-drivers" "homebrew/cask-fonts" "homebrew/cask-versions" "homebrew/core" "homebrew/services" "nrlquaker/createzap" "unisonweb/unison" ]; homebrew.masApps = { Bitwarden = 1352778147; Spark = 1176895641; Tailscale = 1475387142; Xcode = 497799835; }; # If an app isn't available in the Mac App Store, or the version in the App Store has # limitiations, e.g., Transmit, install the Homebrew Cask. homebrew.casks = [ "aerial" "alfred" "bartender" "discord" "element" "firefox" "jitsi-meet" "knockknock" "lagrange" "logitech-options" "lulu" "macsvg" "miniforge" "mullvadvpn" "obsidian" "mullvadvpn" "rectangle" "secretive" "signal" "slack" "stay" "transmission" "utm" "zoom" ] ++ lib.optionals gamesEnabled [ # games "gog-galaxy" "origin" "sony-ps-remote-play" "steam" ]; # Configuration related to casks environment.variables.SSH_AUTH_SOCK = mkIfCaskPresent "secretive" "${config.home.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh"; # For cli packages that aren't currently available for macOS in `nixpkgs`.Packages should be # installed in `../home/default.nix` whenever possible. homebrew.brews = [ "ffmpeg" "fileicon" "fzf" "gifsicle" "tarsnap" "unison-language" ]; }