switch from nix-darwin control to more home-manager darwin settings

This commit is contained in:
Noah Masur
2026-07-05 14:34:43 -06:00
parent e0fb590314
commit 35d40ca346
14 changed files with 505 additions and 106 deletions
@@ -202,6 +202,9 @@ in
};
};
# Used for macOS
xdg.enable = lib.mkDefault pkgs.stdenv.isDarwin;
xdg.desktopEntries.aerc = lib.mkIf (pkgs.stdenv.isLinux) {
name = "aerc";
exec = "${lib.getExe config.nmasur.presets.services.i3.terminal} -e aerc %u";
@@ -13,13 +13,35 @@ in
options.nmasur.presets.programs.fish-darwin.enable = lib.mkEnableOption {
description = "Fish macOS options";
default = config.nmasur.presets.programs.fish && pkgs.stdenv.isDarwin;
};
config = lib.mkIf cfg.enable {
programs.fish.shellAbbrs = {
# Shortcut to edit hosts file
hosts = "sudo nvim /etc/hosts";
# Default shell setting doesn't work
home.sessionVariables = {
SHELL = "${pkgs.fish}/bin/fish";
};
programs.fish = {
shellAbbrs = {
# Shortcut to edit hosts file
hosts = "sudo hx /etc/hosts";
};
shellInit = ''
set -g __nixos_path_original $PATH
function __nixos_path_fix -d "fix PATH value"
set -l result (string split ":" $__nixos_path_original)
for elt in $PATH
if not contains -- $elt $result
set -a result $elt
end
end
set -g PATH $result
end
__nixos_path_fix
'';
# # Speeds up fish launch time on macOS
# useBabelfish = true;
};
};
}
@@ -16,13 +16,12 @@ in
config = lib.mkIf cfg.enable {
# Set the i3 terminal
nmasur.presets.services.i3.terminal =
if pkgs.stdenv.isDarwin then pkgs.alacritty else config.programs.ghostty.package;
nmasur.presets.services.i3.terminal = config.programs.ghostty.package;
programs.ghostty = {
enable = true;
package = if pkgs.stdenv.isDarwin then null else pkgs.ghostty;
package = if pkgs.stdenv.isDarwin then pkgs.ghostty-bin else pkgs.ghostty;
enableFishIntegration = true;
enableBashIntegration = true;
@@ -0,0 +1,82 @@
{
config,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.homebrew;
in
{
options.nmasur.presets.programs.homebrew.enable =
lib.mkEnableOption "Homebrew macOS package manager";
config = lib.mkIf cfg.enable {
home.file.".Brewfile".text = /* homebrew */ ''
# Taps
# tap "homebrew/bundle"
# Brews (CLI Apps)
brew "trash" # Delete files and folders to trash instead of rm
# Casks (GUI Apps)
cask "scroll-reverser" # Different scroll style for mouse vs. trackpad
cask "notunes" # Don't launch Apple Music with the play button
cask "topnotch" # Darkens the menu bar to complete black
cask "ghostty" # Terminal application (not buildable on Nix on macOS)
# Mac App Store apps (requires 'mas' CLI, optional)
# mas "Tailscale", id: 1475387142
'';
# Add homebrew paths to CLI path
home.sessionPath = [
"/opt/homebrew/bin/"
"/opt/homebrew/opt/trash/bin"
];
programs.fish.shellAbbrs.t = "trash";
home.activation.backendBrewBundle = /* bash */ ''
# Requires Homebrew to be installed
if ! /usr/bin/xcode-select --version 2>/dev/null; then
$DRY_RUN_CMD /usr/bin/xcode-select --install
fi
if ! /opt/homebrew/bin/brew --version 2>/dev/null; then
$DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
verboseEcho "Syncing Homebrew dependencies via Brewfile..."
# Ensure Homebrew is in the PATH for the script (Apple Silicon path)
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
# Keep activation deterministic and non-interactive. Without this, brew
# auto-updates (git-fetches its taps) which can hang forever when there
# is no TTY (network stall, credential prompt, or a leftover brew lock).
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ENV_HINTS=1
# Point brew at the generated Brewfile in the Nix store directly. This
# avoids depending on the ~/.Brewfile symlink being linked first, and
# sidesteps the --global vs. inherited HOMEBREW_BUNDLE_FILE conflict.
unset HOMEBREW_BUNDLE_FILE
brewfile="${config.home.file.".Brewfile".source}"
if command -v brew &> /dev/null; then
# Install/upgrade everything declared in the Brewfile...
$DRY_RUN_CMD brew bundle install --file="$brewfile"
# ...then uninstall anything NOT listed (replaces deprecated --cleanup).
$DRY_RUN_CMD brew bundle cleanup --file="$brewfile" --force
else
verboseEcho "Warning: Homebrew not found. Actions skipped."
fi
'';
};
}