The creator of the homebrew package manager is playing with the word brew which stands for the process of preparing a beer. The brew uses the package manager uses terminology that relates to brewing process. The term that we use for the repository in the debian world here is called tap. While, the term used for package is called Formula.

Homebrew Formula differs from the Debain package in that homebrew formula does not contain the actual software but contains instruction on how those softwared can be build. The homebrew forumula is just a ruby files that has instruction of how to compile the source code and how those files are placed on the system. Therefore, creating a homebrew package means you write a ruby class which has instruction on how the software source is to be installed on the system.

Moreover, the homebrew repository/tap is just a github repo containing those ruby Formulas. If we create a repo in a github named homebrew-<repo_name> then we can tap into that repository by using following command.

brew tap <github_username>/<repo_name>

This tutorial will guide you to the process of creating your first homebrew package and hosting it on your tap.

Create a sample package Link to heading

Brew package manager generates you a template of the brew formula if you just type the following command.

brew create <url_to_release_code>

The url can be a source tar ball or even the github repo. This will generate a simple ruby Formula like shown in example below.

class Foo < Formula
  desc ""
  homepage ""
  url ""
  sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7"
  license ""

  # depends_on "cmake" => :build

  def install
    # ENV.deparallelize
    system "./configure", "--disable-debug",
    # system "cmake", ".", *std_cmake_args
    system "make", "install"

  test do
    system "false"

You will just have to modify the above formula which will be located on /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/foo.rb. For a simple package that does not need to compile any code but just install some script you can add bin.install “<executable_file>” or man1.install “” to place them in appropriate place such that they are in path and manpages can be opened using man <binary_file_name> repectively,

Hosting your tap Link to heading

As I have mentioned previously the tap is just a repo containing formulas. We can have multiple formulas in a tap and it needs to be located in Formula directory of the repository. When we tap into the repository it just clones the Formula into the local system.

Private Formulas. Link to heading

If you dont want to host a public formula but want to share a private packages in your office. You can use a private repo that does not even have to hosted in a github. You will need to pass additional parameter i.e git url in the brew tap command so that it finds the actual repository. It will ask for credentials if that is required for the repository.