4[](http://hackage.haskell.org/package/cabal2nix)
5[](http://stackage.org/lts/package/cabal2nix)
6[](http://stackage.org/nightly/package/cabal2nix)
7[](https://travis-ci.org/NixOS/cabal2nix)
9`cabal2nix` converts a single Cabal file into a single Nix build expression.
12 $ cabal2nix cabal://mtl
13 { mkDerivation, base, stdenv, transformers }:
17 sha256 = "1icdbj2rshzn0m1zz5wa7v3xvkf6qw811p4s7jgqwvx1ydwrvrfa";
18 libraryHaskellDepends = [ base transformers ];
19 homepage = "http://github.com/ekmett/mtl";
20 description = "Monad classes, using functional dependencies";
21 license = stdenv.lib.licenses.bsd3;
24Cabal files can be referred to using the magic URL `cabal://NAME-VERSION`,
25which will automatically download the file from Hackage. Alternatively, a
26direct `http://host/path/pkg.cabal` URL can be provided, as well as a
27`file:///local/path/pkg.cabal` URI that doesn't depend on network access.
28However, if the source hash is not already in `cabal2nix`'s cache or provided
29using the `--sha256` option, `cabal2nix` still needs to download the source
30code to compute the hash, which still causes network traffic. Run the utility
31with `--help` to see the complete list of supported command-line flags.
33Detailed instructions on how to use those generated files with Nix can be found at
34https://nixos.org/nixpkgs/manual/#how-to-create-nix-builds-for-your-own-private-haskell-packages.
36`cabal2nix` can also build derivations for projects from other sources than
37Hackage. You only need to provide a URI that points to a cabal project. The
38most common use-case for this is probably to generate a derivation for a
39project on the local file system:
41 $ cabal get mtl-2.2.1 && cd mtl-2.2.1
43 { mkDerivation, base, stdenv, transformers }:
48 libraryHaskellDepends = [ base transformers ];
49 homepage = "http://github.com/ekmett/mtl";
50 description = "Monad classes, using functional dependencies";
51 license = stdenv.lib.licenses.bsd3;
54This derivation will not fetch from hackage, but instead use the directory which
55contains the derivation as the source repository.
57`cabal2nix` currently supports the following repository types:
60* source archive (zip, tar.gz, ...) from http or https URL or local file.
61* git, mercurial, svn or bazaar repository
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list