init
This commit is contained in:
177
modules/darwin/homebrew.nix
Normal file
177
modules/darwin/homebrew.nix
Normal file
@@ -0,0 +1,177 @@
|
||||
# Homebrew cask management via nix-darwin
|
||||
#
|
||||
# This module manages Homebrew packages declaratively through nix-darwin.
|
||||
# It handles taps, formulae, and casks with separate options for shared
|
||||
# and personal-only packages.
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.modules.homebrew;
|
||||
in {
|
||||
options.modules.homebrew = {
|
||||
enable = mkEnableOption "Homebrew management via nix-darwin";
|
||||
|
||||
# Cask categories
|
||||
casks = {
|
||||
shared = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
# Password management
|
||||
"1password"
|
||||
"1password-cli"
|
||||
|
||||
# Terminal & Development
|
||||
"ghostty"
|
||||
"dbeaver-community"
|
||||
"lens"
|
||||
|
||||
# Window management
|
||||
"aerospace"
|
||||
|
||||
# Productivity
|
||||
"raycast"
|
||||
"obsidian"
|
||||
|
||||
# Media
|
||||
"jellyfin-media-player"
|
||||
"ollama-app"
|
||||
|
||||
# Networking & IoT
|
||||
"localsend"
|
||||
"home-assistant"
|
||||
];
|
||||
description = "Homebrew casks to install on all machines";
|
||||
};
|
||||
|
||||
personal = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
# Photography
|
||||
"darktable"
|
||||
|
||||
# Privacy & Security (Proton suite)
|
||||
"proton-mail-bridge"
|
||||
"proton-pass"
|
||||
"protonvpn"
|
||||
|
||||
# Communication
|
||||
"signal"
|
||||
|
||||
# Gaming
|
||||
"steam"
|
||||
];
|
||||
description = "Homebrew casks to install only on personal machines";
|
||||
};
|
||||
|
||||
enablePersonal = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Whether to install personal-only casks";
|
||||
};
|
||||
|
||||
work = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
# Communication
|
||||
"slack"
|
||||
"pritunl"
|
||||
];
|
||||
description = "Homebrew casks to install only on work machines";
|
||||
};
|
||||
|
||||
enableWork = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Whether to install work-only casks";
|
||||
};
|
||||
};
|
||||
|
||||
# Homebrew formulae (for packages not available or preferred from Homebrew)
|
||||
brews = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
# These are from custom taps or preferred from Homebrew
|
||||
"coder/coder/coder"
|
||||
"fluxcd/tap/flux"
|
||||
"nvm"
|
||||
"sst/tap/opencode"
|
||||
"tree-sitter-cli"
|
||||
];
|
||||
description = "Homebrew formulae to install (for packages not in nixpkgs)";
|
||||
};
|
||||
|
||||
# Required taps
|
||||
taps = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
"coder/coder"
|
||||
"felixkratz/formulae"
|
||||
"fluxcd/tap"
|
||||
"nikitabobko/tap"
|
||||
"sst/tap"
|
||||
];
|
||||
description = "Homebrew taps to add";
|
||||
};
|
||||
|
||||
# Cleanup behavior
|
||||
cleanup = mkOption {
|
||||
type = types.enum ["none" "uninstall" "zap"];
|
||||
default = "zap";
|
||||
description = ''
|
||||
Cleanup behavior for Homebrew packages:
|
||||
- none: Don't remove anything
|
||||
- uninstall: Remove packages not in the configuration
|
||||
- zap: Remove packages and their associated files (most aggressive)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# Enable Homebrew support in nix-darwin
|
||||
homebrew = {
|
||||
enable = true;
|
||||
|
||||
# Activation settings
|
||||
onActivation = {
|
||||
# Auto-update Homebrew itself
|
||||
autoUpdate = true;
|
||||
# Upgrade outdated packages
|
||||
upgrade = true;
|
||||
# Cleanup behavior for unmanaged packages
|
||||
cleanup = cfg.cleanup;
|
||||
};
|
||||
|
||||
# Global settings
|
||||
global = {
|
||||
# Don't auto-update before every brew command
|
||||
autoUpdate = false;
|
||||
# Use Brewfile lockfile
|
||||
brewfile = true;
|
||||
};
|
||||
|
||||
# Taps (third-party repositories)
|
||||
taps = cfg.taps;
|
||||
|
||||
# Formulae (CLI tools from Homebrew)
|
||||
brews = cfg.brews;
|
||||
|
||||
# Casks (GUI applications)
|
||||
casks =
|
||||
cfg.casks.shared
|
||||
++ (
|
||||
if cfg.casks.enablePersonal
|
||||
then cfg.casks.personal
|
||||
else []
|
||||
)
|
||||
++ (
|
||||
if cfg.casks.enableWork
|
||||
then cfg.casks.work
|
||||
else []
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user