diff --git a/flake.lock b/flake.lock index a21adee..53106a0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,22 @@ { "nodes": { + "brew-src": { + "flake": false, + "locked": { + "lastModified": 1753461463, + "narHash": "sha256-kGc7pRH0diLzKmOHsEFA8sZ9NJpgT+tqxAMsuqNd5Po=", + "owner": "Homebrew", + "repo": "brew", + "rev": "4d14be89e99a45181c18e96a5f19a5b43343cc0f", + "type": "github" + }, + "original": { + "owner": "Homebrew", + "ref": "4.5.13", + "repo": "brew", + "type": "github" + } + }, "claude-code": { "inputs": { "flake-utils": "flake-utils", @@ -167,6 +184,24 @@ "type": "github" } }, + "nix-homebrew": { + "inputs": { + "brew-src": "brew-src" + }, + "locked": { + "lastModified": 1754250993, + "narHash": "sha256-MEin+qoQKtFC1b0f4tnQ+Z82BQWSCgh6Ef7rpmH9gig=", + "owner": "zhaofengli", + "repo": "nix-homebrew", + "rev": "314d057294e79bc2596972126b84c6f9f144499a", + "type": "github" + }, + "original": { + "owner": "zhaofengli", + "repo": "nix-homebrew", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1753432016, @@ -251,6 +286,7 @@ "firefox-addons": "firefox-addons", "home-manager": "home-manager", "nix-darwin": "nix-darwin", + "nix-homebrew": "nix-homebrew", "nixpkgs": "nixpkgs_2", "nixvim": "nixvim" } diff --git a/flake.nix b/flake.nix index f0f9768..4869d9a 100644 --- a/flake.nix +++ b/flake.nix @@ -14,9 +14,10 @@ url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons"; inputs.nixpkgs.follows = "nixpkgs"; }; + nix-homebrew.url = "github:zhaofengli/nix-homebrew"; }; - outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager, nixvim, claude-code, firefox-addons }: + outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager, nixvim, claude-code, firefox-addons, nix-homebrew }: let configuration = { pkgs, ... }: { imports = [ @@ -103,11 +104,17 @@ in { darwinConfigurations."iMac" = nix-darwin.lib.darwinSystem { - modules = [ configuration ]; + modules = [ + configuration + nix-homebrew.darwinModules.nix-homebrew + ]; }; darwinConfigurations."MacBook-Air" = nix-darwin.lib.darwinSystem { - modules = [ configuration ]; + modules = [ + configuration + nix-homebrew.darwinModules.nix-homebrew + ]; }; homeConfigurations.yanlin = home-manager.lib.homeManagerConfiguration { diff --git a/modules/homebrew.nix b/modules/homebrew.nix new file mode 100644 index 0000000..1c5970d --- /dev/null +++ b/modules/homebrew.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: + +{ + # Homebrew configuration for package management + homebrew = { + enable = true; + onActivation = { + autoUpdate = true; + cleanup = "zap"; # Removes unlisted formulae/casks + upgrade = true; + }; + brews = [ + # Command-line tools go here + # Example: "wget" + ]; + casks = [ + # GUI applications go here + # Example: "google-chrome" + ]; + taps = [ + # Additional repositories if needed + ]; + }; +} diff --git a/modules/nix-homebrew.nix b/modules/nix-homebrew.nix new file mode 100644 index 0000000..9481b41 --- /dev/null +++ b/modules/nix-homebrew.nix @@ -0,0 +1,11 @@ +{ config, pkgs, ... }: + +{ + # nix-homebrew configuration for declarative Homebrew installation + nix-homebrew = { + enable = true; + enableRosetta = true; # Apple Silicon support + user = "yanlin"; + autoMigrate = true; # Migrate existing Homebrew if present + }; +} \ No newline at end of file diff --git a/modules/zsh.nix b/modules/zsh.nix index 9239754..9eba79c 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -113,6 +113,8 @@ in app_path=$( (find -L /Applications -name "*.app" -maxdepth 2 2>/dev/null; \ find -L ~/Applications -name "*.app" -maxdepth 3 2>/dev/null; \ + find -L /opt/homebrew/Caskroom -name "*.app" -maxdepth 3 2>/dev/null; \ + find -L /usr/local/Caskroom -name "*.app" -maxdepth 3 2>/dev/null; \ find /System/Applications -name "*.app" -maxdepth 2 2>/dev/null; \ find /System/Applications/Utilities -name "*.app" -maxdepth 1 2>/dev/null) | sort | uniq | diff --git a/system/macos-defaults.nix b/system/macos-defaults.nix index 64ba6eb..d02c639 100644 --- a/system/macos-defaults.nix +++ b/system/macos-defaults.nix @@ -1,6 +1,11 @@ { config, pkgs, ... }: { + imports = [ + ../modules/homebrew.nix + ../modules/nix-homebrew.nix + ]; + # Set primary user for system preferences system.primaryUser = "yanlin";