git.iko.soy/typeable/cabal2nix
on v2.15.0 help sign in
61 lines 2.8 kB history raw
1Cabal2nix
2=========
4[![hackage release](https://img.shields.io/hackage/v/cabal2nix.svg?label=hackage)](http://hackage.haskell.org/package/cabal2nix)
5[![stackage LTS package](http://stackage.org/package/cabal2nix/badge/lts)](http://stackage.org/lts/package/cabal2nix)
6[![stackage Nightly package](http://stackage.org/package/cabal2nix/badge/nightly)](http://stackage.org/nightly/package/cabal2nix)
7[![travis build status](https://img.shields.io/travis/NixOS/cabal2nix/master.svg?label=travis+build)](https://travis-ci.org/NixOS/cabal2nix)
9`cabal2nix` converts a single Cabal file into a single Nix build expression.
10For example:
12 $ cabal2nix cabal://mtl
13 { mkDerivation, base, stdenv, transformers }:
14 mkDerivation {
15 pname = "mtl";
16 version = "2.2.1";
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;
22 }
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 obviously still causes network traffic. Run the
31utility with `--help` to see the complete list of supported command line flags.
33Detailed instructions 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 an URI that points to a cabal project. The
38most common usecase for this is probably to generate a derivation for a project
39on the local file system:
41 $ cabal get mtl-2.2.1 && cd mtl-2.2.1
42 $ cabal2nix .
43 { mkDerivation, base, stdenv, transformers }:
44 mkDerivation {
45 pname = "mtl";
46 version = "2.2.1";
47 src = ./.;
48 libraryHaskellDepends = [ base transformers ];
49 homepage = "http://github.com/ekmett/mtl";
50 description = "Monad classes, using functional dependencies";
51 license = stdenv.lib.licenses.bsd3;
52 }
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:
59* directory
60* source archive (zip, tar.gz, ...) from http or https URL or local file.
61* git, mercurial, svn or bazaar repository