A fork of haskell.nix with a more efficient GHCJS 8.10 compiler
Go to file
2020-06-02 16:45:54 +12:00
.buildkite Replace collectRunComponents with haskellLib.check (#316) 2019-11-29 23:28:47 +13:00
builder Faster profiled builds (#623) 2020-05-22 21:50:05 +08:00
compiler Drop -fast-llvm 2020-05-21 12:42:35 +08:00
docs Improve nix-tools installation guide (#639) 2020-05-31 11:07:39 +08:00
examples Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
lib Add support for cabal.project.local (#632) 2020-06-01 23:12:24 +12:00
materialized Add #! to dummy-ghc, --version and use bash case (#640) 2020-06-01 14:46:49 +12:00
mk-local-hackage-repo Update ghc 8.4.4 based tools to ghc 8.6.5 (#618) 2020-05-21 11:31:26 +12:00
modules Include terminfo in nonReinstallablePkgs for reinstallableLibGhc (#606) 2020-05-15 19:02:41 +08:00
nix Add niv sources at haskell-nix.sources (#622) 2020-05-21 15:39:39 +12:00
nix-tools Update ghc 8.4.4 based tools to ghc 8.6.5 (#618) 2020-05-21 11:31:26 +12:00
nixpkgs Add niv sources at haskell-nix.sources (#622) 2020-05-21 15:39:39 +12:00
overlays Add missing pins and test ghc865 and ghc883 (#641) 2020-06-02 11:44:03 +12:00
patches Fix singletons patch (#409) 2020-01-21 17:10:48 +08:00
pkgs Overlays (#261) 2019-10-21 20:07:58 +08:00
scripts Update nixpkgs pins to include 20.03 (#557) 2020-04-29 02:49:36 +12:00
test Add missing pins and test ghc865 and ghc883 (#641) 2020-06-02 11:44:03 +12:00
.gitattributes Update ghc 8.4.4 based tools to ghc 8.6.5 (#618) 2020-05-21 11:31:26 +12:00
.gitignore bump nix tools (#476) 2020-03-06 17:19:45 +08:00
bors.toml Add bors.toml to enable bors 2020-03-05 12:22:57 +13:00
build.nix Add cabal-install and hpack to closure size check (#645) 2020-06-02 16:45:54 +12:00
changelog.md Change LLVM versions for ghc-8.6 to LLVM 6 (#385) 2020-01-07 19:12:32 +13:00
ci-lib.nix Add pins and materialization for ghc-boot-packages and ghc-extra-packages (#546) 2020-04-20 13:27:52 +12:00
ci.nix Add missing pins and test ghc865 and ghc883 (#641) 2020-06-02 11:44:03 +12:00
config.nix Update nixpkgs pins to include 20.03 (#557) 2020-04-29 02:49:36 +12:00
COPYING License Apache 2.0 2019-04-29 11:08:31 +08:00
default.nix Add niv sources at haskell-nix.sources (#622) 2020-05-21 15:39:39 +12:00
dimension.nix Tidy ci.nix using dimension (#500) 2020-03-20 20:52:34 +13:00
flake.nix Update ghc 8.4.4 based tools to ghc 8.6.5 (#618) 2020-05-21 11:31:26 +12:00
hackage-src.json Update Hackage and Stackage 2020-06-02 01:17:00 +00:00
mkdocs.yml Split out introdocution into motivation, add features, prepare getting started (#634) 2020-05-31 11:06:02 +08:00
package-set.nix Update ghc 8.4.4 based tools to ghc 8.6.5 (#618) 2020-05-21 11:31:26 +12:00
README.md README: 20.03 (#636) 2020-05-29 23:11:52 +08:00
release.nix Add missing pins and test ghc865 and ghc883 (#641) 2020-06-02 11:44:03 +12:00
shell.nix Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
snapshots.nix fix #269. Apply fix to mkStackPkgSet (#310) 2019-11-09 17:01:04 +13:00
stackage-src.json Update Hackage and Stackage 2020-06-01 01:16:28 +00:00

haskell.nix is infrastructure for building Haskell packages with Nix

haskell.nix can automatically translate your Cabal or Stack project and its dependencies into Nix code.

Documentation

Getting started

a) Using cabal.project

Add a default.nix:

let 
  # Fetch the latest haskell.nix and import its default.nix
  haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};

  # haskell.nix provides access to the nixpkgs pins which are used by our CI, hence
  # you will be more likely to get cache hits when using these.
  # But you can also just use your own, e.g. '<nixpkgs>'
  nixpkgsSrc = haskellNix.sources.nixpkgs-2003;

  # haskell.nix provides some arguments to be passed to nixpkgs, including some patches
  # and also the haskell.nix functionality itself as an overlay.
  nixpkgsArgs = haskellNix.nixpkgsArgs;
in
{ pkgs ? import nixpkgsSrc nixpkgsArgs
, haskellCompiler ? "ghc865"
}:

# 'cabalProject' generates a package set based on a cabal.project (and the corresponding .cabal files)
pkgs.haskell-nix.cabalProject {
  # 'cleanGit' cleans a source directory based on the files known by git
  src = pkgs.haskell-nix.haskellLib.cleanGit { name = "haskell-nix-project"; src = ./.; };
  compiler-nix-name = haskellCompiler;
}

Note that you'll need to add a comment specifying the expected sha256 output for your source-repository-packages in your cabal.project file:

source-repository-package
  type: git
  location: https://github.com/input-output-hk/iohk-monitoring-framework
  subdir:   plugins/backend-editor
  tag: 4956b32f039579a0e7e4fd10793f65b4c77d9044
  --sha256: 03lyb2m4i6p7rpjqarnhsx21nx48fwk6rzsrx15k6274a4bv0pix

b) Using stack.yaml

Add a default.nix:

let 
  haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
  nixpkgsSrc = haskellNix.sources.nixpkgs-2003;
  nixpkgsArgs = haskellNix.nixpkgsArgs;
in
{ pkgs ? import nixpkgsSrc nixpkgsArgs
}:
pkgs.haskell-nix.stackProject {
  src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
}

To build the library component of a package in the project run:

nix build -f . your-package-name.components.library

To build an executable:

nix build -f . your-package-name.components.exes.your-exe-name

To open a shell for use with cabal run:

nix-shell -A shellFor
cabal new-build your-package-name
cabal new-repl your-package-name:library:your-package-name

Using binary Cache to speed up compilation

To use precompiled binaries you'll need:

The haskell.nix repository contains the runtime system for building Haskell packages in Nix. It depends on other repos, which are:

  • nix-tools — provides the programs for generating Nix expressions from Haskell projects.

  • hackage.nix — the latest contents of the Hackage databases, converted to Nix expressions.

  • stackage.nix — all of the Stackage snapshots, converted to Nix expressions.

IRC Channel

Join the #haskell.nix channel on irc.freenode.net to get help or discuss the development of haskell.nix and nix-tools.