git.iko.soy/typeable/cabal2nix
on v2.8 help sign in
56 lines 2.3 kB history raw
1Cabal2nix
2=========
4`cabal2nix` converts a single Cabal file into a single Nix build expression.
5For example:
7 $ cabal2nix cabal://mtl
8 { mkDerivation, base, stdenv, transformers }:
9 mkDerivation {
10 pname = "mtl";
11 version = "2.2.1";
12 sha256 = "1icdbj2rshzn0m1zz5wa7v3xvkf6qw811p4s7jgqwvx1ydwrvrfa";
13 libraryHaskellDepends = [ base transformers ];
14 homepage = "http://github.com/ekmett/mtl";
15 description = "Monad classes, using functional dependencies";
16 license = stdenv.lib.licenses.bsd3;
17 }
19Cabal files can be referred to using the magic URL `cabal://NAME-VERSION`,
20which will automatically download the file from Hackage. Alternatively, a
21direct `http://host/path/pkg.cabal` URL can be provided, as well as a
22`file:///local/path/pkg.cabal` URI that doesn't depend on network access.
23However, if the source hash is not already in `cabal2nix`'s cache or provided
24using the `--sha256` option, `cabal2nix` still needs to download the source
25code to compute the hash, which obviously still causes network traffic. Run the
26utility with `--help` to see the complete list of supported command line flags.
28Detailed instructions how to use those generated files with Nix can be found at
29http://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure.
31`cabal2nix` can also build derivations for projects from other sources than
32hackage. You only need to provide an URI that points to a cabal project. The
33most common usecase for this is probably to generate a derivation for a project
34on the local file system:
36 $ cabal get mtl-2.2.1 && cd mtl-2.2.1
37 $ cabal2nix .
38 { mkDerivation, base, stdenv, transformers }:
39 mkDerivation {
40 pname = "mtl";
41 version = "2.2.1";
42 src = ./.;
43 libraryHaskellDepends = [ base transformers ];
44 homepage = "http://github.com/ekmett/mtl";
45 description = "Monad classes, using functional dependencies";
46 license = stdenv.lib.licenses.bsd3;
47 }
49This derivation will not fetch from hackage, but instead use the directory which
50contains the derivation as the source repository.
52`cabal2nix` currently supports the following repository types:
54* directory
55* source archive (zip, tar.gz, ...) from http or https URL or local file.
56* git, mercurial, svn or bazaar repository