(initial introduction to Hack-Nix which is another cabal project manager based on Nix.)
|(3 intermediate revisions by 2 users not shown)|
Revision as of 03:25, 13 November 2012
Hack-Nix is a cabal package management tool using the pure package manager nix.
The most up to date description can be found at the nixos wiki: 
1 Why do you want to use Hack-Nix?
- setup build environments for different combinations of cabal flags and ghc versions
- if an upgrade didn't work just rollback to the previous working setup
- manage patches independently of hackage to make packages compile
- It works the same way no matter which linux distribution you're using
- run the garbage collector occasionally instead of bothering about uninstalling packages manually
If you're only interested in a minimal stable set of packages which is provided by the haskell platform you don't need hack-nix.
2 Usage example
# cd into a project directory containing a .cabal file # create the configuration file ".hack-nix-cabal-config": WAY1:[("haskellPackages","haskellPackages_ghc682"),("flags","curl"),("mergeBy","ways/base3.nix")] # The ways/base3.nix file let's you override and # replace all packages in the dependency chain. # In this example it's used to remove base >= 4 from the # list of available packages. $ hack-nix --build-env WAY1 # now the dependency solver written in nix starts its job and compiles all # dependencies required by your project. You can set cabal flags using # a configuration file. On success it'll print: success: # source: source hack-nix-envs/WAY1/source-me/haskell-env # and configure [ -e Setup ] || ghc --make Setup.hs ./Setup clean ./Setup configure --builddir=distWAY1 --flags "WAY1" && ./Setup build
3 How does it work?
The source-me/haskell-env file exports PATH so that the ghc you chose earlier and the libraries are found by cabal. Nix specific ghc(-*) wrappers are used to accomplish this.
4 On which OS Hack-Nix be used?
The set of tools is based on Nix, which performs best on any Linux. It can be installed on Cygwin but I haven't tested this at all. Nix installs into /nix and puts packages into /nix/store by default. You can make it live within $HOME only as well.
Install nix. Please read the documentation found on the project homepage. If you've trouble join #nixos on freenode or join the mailinglist.
Get these repositories: [ http://github.com/MarcWeber/haskell-nix-overlay haskell-nix-overaly ] [ http://github.com/MarcWeber/hack-nix hack-nix ] Follow the instructions given in the hack-nix README file.
6 HOWTO uninstall a package
Brief: nix behaves like a memory manager. You run the garbage collector and all packages which are no longer referenced by any environment are removed automatically for you.
7 required quota
I haven't tested yet. Nix by default installs everything from scratch including glibc etc. There are solutions to make it work with libraries which are present on your system. However I haven't tried it because I'm running Nixos myself.
8 HOWTO make Hack-Nix know about my package ?
$ cd projectdir; hack-nix --to-nix
This will create a dist/name.nix file. You can add this to your ~/nixpkgs/config.nix file. Alternative: Tell hack-nix about additional packages in a configuration file. See mergeWith example above.
9 I've got a question
The purpose of this wiki page is telling you about the existence of this package rather than providing all details. This is work in progress. Up to date information can be found in the README file. I'm pretty sure I've missed important things you're interested in. Join irc on freenode and contact me (MarcWeber). I'm going to improve documentation ASAP. Of course I want you to participate in this project :-)
10 How does it compare to cabal install ?
The solver is written in the Nix language (right now). So it is slower. The advantages are that it optionally creates tag files for you. You never have to think about which packages to upgrade and about its consequences. You create a unique setup for project you're working on and that's it. If one package requires parsec-2 and another requires parsec-3 that's no problem. You never uninstall packages. You run the garbage collector once a month or so. Nix will install C library dependencies such as readline or postgresql automatically. cabal install is faster because it doesn't even compile Setup.hs each time. Nix starts a new build job for each dependency. Nix supports concurrent builds. Hack-Nix will never replace cabal install. It is an optional tool written for maintainers who have to handle multiple setups.