cabal2nix

Generate Nix build instructions from a Cabal file

Github星跟蹤圖

Cabal2nix

hackage release
stackage LTS package
stackage Nightly package
travis build status

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";
  libraryHaskellDepends = [ 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 still causes network traffic. Run the utility
with --help to see the complete list of supported command-line flags.

Detailed instructions on how to use those generated files with Nix can be found at
https://nixos.org/nixpkgs/manual/#how-to-create-nix-builds-for-your-own-private-haskell-packages.

cabal2nix can also build derivations for projects from other sources than
Hackage. You only need to provide a URI that points to a cabal project. The
most common use-case 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 = ./.;
  libraryHaskellDepends = [ 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 repository types:

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

主要指標

概覽
名稱與所有者NixOS/cabal2nix
主編程語言Haskell
編程語言Haskell (語言數: 3)
平台
許可證Other
所有者活动
創建於2011-08-05 15:31:37
推送於2025-06-14 12:05:36
最后一次提交2025-06-14 14:05:36
發布數141
最新版本名稱cabal2nix-v2.20.1 (發布於 2025-05-10 12:09:20)
第一版名稱v1.0 (發布於 2011-08-05 18:40:57)
用户参与
星數375
關注者數15
派生數154
提交數2.6k
已啟用問題?
問題數323
打開的問題數77
拉請求數275
打開的拉請求數11
關閉的拉請求數45
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?