Difference between revisions of "Hack-Nix"

From HaskellWiki
Jump to navigation Jump to search
Line 2: Line 2:
   
 
== Why do you want to use Hack-Nix? ==
 
== Why do you want to use Hack-Nix? ==
* setup build environments for different combinations of cabal flags and ghc versions
+
* 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
 
* if an upgrade didn't work just rollback to the previous working setup
 
* manage patches independently of hackage to make packages compile
 
* manage patches independently of hackage to make packages compile
 
* install gtk2hs and depending packages
 
* install gtk2hs and depending packages
 
* It works the same way no matter which linux distribution you're using
 
* It works the same way no matter which linux distribution you're using
* run the garbage collector ocasionally instead of bothering about uninstalling packages manually
+
* 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.
 
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.
Line 21: Line 21:
 
# replace all packages in the dependency chain.
 
# replace all packages in the dependency chain.
 
# In this example it's used to remove base >= 4 from the
 
# In this example it's used to remove base >= 4 from the
# list of availible packages.
+
# list of available packages.
   
   
Line 71: Line 71:
   
 
== I've got a question ==
 
== I've got a question ==
The purpose of this wiki page is telling you about the existance of this package rather than providing all details.
+
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 [http://github.com/MarcWeber/hack-nix README] file.
 
This is work in progress. Up to date information can be found in the [http://github.com/MarcWeber/hack-nix README] file.
 
I'm pretty sure I've missed important things you're interested in.
 
I'm pretty sure I've missed important things you're interested in.
Line 80: Line 80:
 
== How does it compare to cabal install ? ==
 
== How does it compare to cabal install ? ==
 
The solver is written in the Nix language (right now).
 
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 uniq setup for project you're working on and that's it. If one packgae 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.
+
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.
 
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.
 
It is an optional tool written for maintainers who have to handle multiple setups.

Revision as of 02:22, 12 June 2010

Hack-Nix is a cabal package management tool using the pure package manager nix.

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
  • install gtk2hs and depending packages
  • 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.

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

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.

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.

HOWTO

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.

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.

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.

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.

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 :-)

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.