A fork of haskell.nix with a more efficient GHCJS 8.10 compiler
Go to file
Hamish Mackenzie 79b5458138
Update materialized nix files (#603)
Update materialized with new errorHandler
2020-05-13 22:08:36 +12:00
.buildkite Replace collectRunComponents with haskellLib.check (#316) 2019-11-29 23:28:47 +13:00
builder Add native musl support (#578) 2020-05-08 15:32:40 +08:00
compiler fix: consider relocatable data as writable (#570) 2020-05-09 07:04:50 +08:00
docs Update user-guide.md 2020-05-04 14:06:00 +08:00
examples Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
lib Add native musl support (#578) 2020-05-08 15:32:40 +08:00
materialized Update materialized nix files (#603) 2020-05-13 22:08:36 +12:00
mk-local-hackage-repo External hackages (#535) 2020-05-02 18:16:34 +08:00
modules Fix for errorHandler argument missing issue (#595) 2020-05-11 12:15:05 +08:00
nix-tools Include nix-tools/pull/90 (#601) 2020-05-13 08:19:00 +08:00
nixpkgs Update nixpkgs pins to include 20.03 (#557) 2020-04-29 02:49:36 +12:00
overlays Fix evalDeps package ids with - in name (#585) 2020-05-11 23:58:42 +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 Update default.nix 2020-05-02 19:24:52 +08:00
.gitattributes Overlays (#261) 2019-10-21 20:07:58 +08: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 remove creation of relative links in package db (#569) 2020-05-01 16:49:22 +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 remove creation of relative links in package db (#569) 2020-05-01 16:49:22 +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 pkgs to use nixpkgs-default easily (#602) 2020-05-13 12:29:29 +08:00
dimension.nix Tidy ci.nix using dimension (#500) 2020-03-20 20:52:34 +13:00
flake.nix Flake (#589 and #567) 2020-05-07 11:16:38 +12:00
hackage-src.json Update Hackage and Stackage 2020-05-13 00:39:54 +00:00
mkdocs.yml docs: Add note about shellFor and CABAL_CONFIG (#247) 2019-09-24 08:53:20 +10:00
package-set.nix Externalize error msg functions (#588) 2020-05-09 11:08:45 +08:00
README.org README: some minor fixes (#596) 2020-05-12 08:41:07 +08:00
release.nix ifdLevel 3 2020-05-12 12:07:41 +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 Revert "Update Hackage and Stackage" (#599) 2020-05-12 21:36:12 +08:00

⚠️ Please use iohk.cachix.org instead of nix-tools.cachix.org   warning 

Alternative Haskell Infrastructure for Nixpkgs

https://badge.buildkite.com/d453edcd29bd2f8f3f3b32c9b7d6777a33773d9671c37a6ccc.svg?branch=master https://img.shields.io/buildkite/c8d5a20d3ff0f440f82adb9190b43c16c91e5e47e8adfa867a/master.svg?label=nightly%20updates

haskell.nix is an experimental new builder for Haskell packages.

It works by automatically translating your Cabal or Stack project and its dependencies into Nix code. It provides IFD (import from derivation) functions that can minimize the amount of Nix code you need to add.

For the documentation, see https://input-output-hk.github.io/haskell.nix/.

Quickstart

For cabal.project 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-1909;
  # 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 { src = ./.; };
  ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${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

For a stack.yaml project 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-1909;
  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

Cache

CI pushes to cachix so you can benefit from the cache if you pin a combination of haskell.nix and nixpkgs built by CI.

You'll need to configure the iohk cachix as a substituter for nix and add the public key found at the url to trusted-public-keys.

Related repos

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.