Skip to content

Instantly share code, notes, and snippets.

@thumphries
Last active April 26, 2016 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thumphries/79ebfb39d9bebd04a712 to your computer and use it in GitHub Desktop.
Save thumphries/79ebfb39d9bebd04a712 to your computer and use it in GitHub Desktop.
Mafia quick start

Mafia Quick Start

Mafia is a wrapper for cabal-install that eliminates most of the pain points, without the need for a blessed set of packages.

Install, use, upgrade

Put the wrapper script somewhere on your path:

cd $HOME/bin && wget https://raw.githubusercontent.com/ambiata/mafia/master/script/mafia

Jump into a git repository with a Haskell project inside, and try to build it. This will compile mafia first, then build all dependencies (including any contained in git submodules or the local repository!) in the global cache. Finally, it builds the local cabal project, and all test suites, with -Wall -Werror.

cd $HOME/src/cryptol && mafia build

Upgrade the script to the latest version with mafia upgrade.

Novelty

Zero configuration for typical projects

As long as you have a project in a git repo, mafia build mafia test and mafia bench are all you need. It's especially nice to avoid the elaborate sandbox dance when using local dependencies, which are found automatically from any directory or submodule in the repo. (One condition: the top-level project you're building cannot be in a submodule.)

Caching

The global cache is cool. After building each dependency and placing it in the global cache, mafia takes cabal's buildplan and links each dep into a local sandbox:

cd /tmp
git clone https://github.com/GaloisInc/cryptol
cd cryptol
mafia build # All deps cached from last time

... although it can grow quite large over time, as it is forced to consider the transitive set of dependencies, the hashes of each file in the package's sdist, and the sdist file list itself.

GHC-hopping

If you are maintaining software between various versions of GHC, mafia turns this into a zero-effort endeavour (excepting the time it takes to compile all of your dependencies once.) Each version has its own global cache, so rebuilding the project sandbox with symlinks takes no time at all. Just put a different GHC onto your path, and things should just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment