Skip to content

Commit

Permalink
Document Nix integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ttuegel committed Dec 3, 2016
1 parent 3ab3ddc commit 4489722
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cabal/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Welcome to the Cabal User Guide
concepts-and-development
bugs-and-stability
nix-local-build-overview
nix-integration
40 changes: 40 additions & 0 deletions Cabal/doc/nix-integration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Nix Integration
===============

`Nix <http://nixos.org/nix/>`_ is a package manager popular with some Haskell developers due to its focus on reliability and reproducibility. ``cabal`` now has the ability to integrate with Nix for dependency management during local package development.

Enabling Nix Integration
------------------------

To enable Nix integration, simply pass the ``--enable-nix`` global option when you call ``cabal``. To use this option everywhere, edit your ``$HOME/.cabal/config`` file to include:

.. code-block:: cabal
nix: True
If the package (which must be locally unpacked) provides a ``shell.nix`` file, this flag will cause ``cabal`` to run most commands through ``nix-shell``. The following commands are affected:

- ``cabal configure``
- ``cabal build``
- ``cabal repl``
- ``cabal install`` (only if installing into a sandbox)
- ``cabal haddock``
- ``cabal freeze``
- ``cabal gen-bounds``
- ``cabal run``

If the package does not provide a ``shell.nix``, ``cabal`` runs normally.

Creating Nix Expressions
------------------------

The Nix package manager is based on a lazy, pure, functional programming language; packages are defined by expressions in this language. The fastest way to create a Nix expression for a Cabal package is with the `cabal2nix <https://github.com/NixOS/cabal2nix>`_ tool. To create a ``shell.nix`` expression for the package in the current directory, run this command:

.. code-block:: console
$ cabal2nix ./. >shell.nix
Further Reading
----------------

The `Nix manual <http://nixos.org/nix/manual/#chap-writing-nix-expressions>`_ provides further instructions for writing Nix expressions. The `Nixpkgs manual <http://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure>`_ describes the infrastructure provided for Haskell packages.

0 comments on commit 4489722

Please sign in to comment.