Git Product home page Git Product logo

cabal2nix's Introduction

Cabal2nix

cabal2nix converts a single Cabal file into a single Nix build expression. For example:

$ cabal2nix cabal://mtl
{ mkDerivation, base, stdenv, transformers }:
mkDerivation {
  pname = "mtl";
  version = "2.2.1";
  sha256 = "1icdbj2rshzn0m1zz5wa7v3xvkf6qw811p4s7jgqwvx1ydwrvrfa";
  buildDepends = [ base transformers ];
  homepage = "http://github.com/ekmett/mtl";
  description = "Monad classes, using functional dependencies";
  license = stdenv.lib.licenses.bsd3;
}

Cabal files can be referred to using the magic URL cabal://NAME-VERSION, which will automatically download the file from Hackage. Alternatively, a direct http://host/path/pkg.cabal URL can be provided, as well as a file:///local/path/pkg.cabal URI that doesn't depend on network access. However, if the source hash is not already in cabal2nix's cache or provided using the --sha256 option, cabal2nix still needs to download the source code to compute the hash, which obviously still causes network traffic. Run the utility with --help to see the complete list of supported command line flags.

Detailed instructions how to use those generated files with Nix can be found at http://hydra.nixos.org/job/nixpkgs/trunk/manual/latest/download-by-type/doc/manual#users-guide-to-the-haskell-infrastructure.

cabal2nix can also build derivations for projects from other sources than hackage. You only need to provide an URI that points to a cabal project. The most common usecase for this is probably to generate a derivation for a project on the local file system:

$ cabal get mtl-2.2.1 && cd mtl-2.2.1
$ cabal2nix .
{ mkDerivation, base, stdenv, transformers }:
mkDerivation {
  pname = "mtl";
  version = "2.2.1";
  src = ./.;
  buildDepends = [ base transformers ];
  homepage = "http://github.com/ekmett/mtl";
  description = "Monad classes, using functional dependencies";
  license = stdenv.lib.licenses.bsd3;
}

This derivation will not fetch from hackage, but instead use the directory which contains the derivation as the source repository.

cabal2nix currently supports the following respository types:

  • directory
  • source archive (zip, tar.gz, ...) from http or https URL or local file.
  • git, mercurial, svn or bazaar repository

How to compile this package

The cabal2nix.cabal file for this package is automatically generated by the generate-cabal-file.hs program. The easiest way to accomplish that is to run

nix-shell release.nix -A cabal2nix.ghc7102.x86_64-linux.env --run "runhaskell generate-cabal-file.hs >cabal2nix.cabal"

where x86_64-linux should be replaced with whatever system ID is appropriate for your local machine. Basically, generate-cabal-file.hs requires the cartel library and git to run.

With the Cabal file in place, this is a normal Haskell project that can be compiled with cabal-install.

Users of Nix can build this package by running

nix-build release.nix -A cabal2nix.ghc7102.x86_64-linux

where, again, x86_64-linux should be replaced with the appropriate value. This gives you an executable at result/bin/cabal2nix. If you'd like to install the latest release version, then

nix-env -f "<nixpkgs>" -iA cabal2nix

is the way to go.

cabal2nix's People

Contributors

abbradar avatar astsmtl avatar aycanirican avatar bennofs avatar bluescreen303 avatar cheecheeo avatar danbst avatar davorak avatar dmalikov avatar drvink avatar fuuzetsu avatar gridaphobe avatar jb55 avatar jraygauthier avatar jwiegley avatar k0001 avatar kosmikus avatar krgn avatar mdorman avatar mwotton avatar nrolland avatar ocharles avatar peti avatar phile314 avatar psibi avatar psub avatar shlevy avatar spencerjanssen avatar supki avatar teh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.