I prefer to reserve the system-level package manager for system-level packages, which my development tools generally are not. As such, my tools are installed in my ~/opt/
directory where possible (then symlinked to ~/bin/
).
In this post, I’m looking at how I did this for my Haskell tool-set.
Haskell’s cabal
is a great dependency management/build tool with built-in sandbox capabilities. It is also often used to install many Haskell tools, such as hlint
, pointfree
and doctest
.
I was originally installing these tools by creating a subdirectory per tool (e.g. ~/opt/haskell/hlint/
) and using cabal sandbox init; cabal install hlint
to install the tool (hlint
in this case) within the sandbox.
But, I didn’t like having a set of “empty” directories (containing only the hidden .cabal-sandbox
and cabal.sandbox.config
). With a few extra arguments (thanks to some tips from Ben Kolera at the last BFPG hack night) we can forgo the superfluous subdirectories and reveal the sandboxes.
Here is an example of installing hlint
:
1 2 3 4 |
|
This creates a sandbox config file called hlint.sandbox.config
and a visible sandbox in the hlint
directory.
You can then symlink the executable onto your path:
1
|
|
This is how I have installed all of these tools and is my currently preferred method. There are other variations on this that can also be used, for instance, adding the package’s bin
directory to your path, or copying the actual executable out of the sandbox (then you could even delete the sandbox if you choose).
This works for all of the packages I mentioned above, and probably any others that you want to install just for the executable binary.