A fork of haskell.nix with a more efficient GHCJS 8.10 compiler
Go to file
2020-04-20 01:12:24 +00:00
.buildkite Replace collectRunComponents with haskellLib.check (#316) 2019-11-29 23:28:47 +13:00
builder fix: not use ld.gold on aarch32 (#548) 2020-04-17 23:54:06 +12:00
compiler fix: not use ld.gold on aarch32 (#548) 2020-04-17 23:54:06 +12:00
docs Add missing import and fix typos in docs (#543) 2020-04-13 01:10:44 +12:00
examples Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
lib Add vulkan-loader to system package map (#528) 2020-04-02 14:52:41 +08:00
materialized build ghcjs (#382) 2020-02-09 20:03:22 +08:00
mk-local-hackage-repo Overlays (#261) 2019-10-21 20:07:58 +08:00
modules fix profilingDetail errors when enabling profiling (#493) 2020-03-17 18:45:56 +13:00
nix-tools Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
nixpkgs Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
overlays {cabal,stack}Project': Expose pkg-set (#531) 2020-04-11 12:44:22 +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 update-index-state-hashes.nix 2020-03-26 14:17:32 +08:00
test Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +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 Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08: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 Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
ci.nix Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
config.nix 19.09 compat (#403) 2020-01-16 16:25:31 +08:00
COPYING License Apache 2.0 2019-04-29 11:08:31 +08:00
default.nix Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
dimension.nix Tidy ci.nix using dimension (#500) 2020-03-20 20:52:34 +13:00
hackage-src.json Update Hackage and Stackage 2020-04-20 01:12:24 +00:00
mkdocs.yml docs: Add note about shellFor and CABAL_CONFIG (#247) 2019-09-24 08:53:20 +10:00
package-set.nix Fix evaluation of haskellLib.collectComponents (#479) 2020-03-09 20:47:26 +10:00
README.org Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08:00
release.nix Expose our nixpkgs pins by restructuring default.nix (#514) 2020-03-31 09:12:40 +08: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-04-20 01:12:24 +00:00

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 (imports from derviation) 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.