on worktree-fix help sign in
haskell.nix/README.org
101 lines 3.9 kB history raw
1#+STARTUP: showall hidestars
3** :warning: The Overlay branch #261 was merged. haskell.nix is now an overlay and the dependency on iohk-nix was dropped. Please see the updated documentation! Once any remaining issues are resolved, this will mark the 1.0 release of haskell.nix. :warning:
5* Alternative Haskell Infrastructure for Nixpkgs
7[[https://buildkite.com/input-output-hk/haskell-dot-nix][https://badge.buildkite.com/d453edcd29bd2f8f3f3b32c9b7d6777a33773d9671c37a6ccc.svg?branch=master]]
8[[https://buildkite.com/input-output-hk/haskell-dot-nix-nightly-updates][https://img.shields.io/buildkite/c8d5a20d3ff0f440f82adb9190b43c16c91e5e47e8adfa867a/master.svg?label=nightly%20updates]]
10=haskell.nix= is an experimental new builder for Haskell packages.
12It works by automatically translating your Cabal or Stack project and
13its dependencies into Nix code. It provides IFD (imports from derviation)
14functions that can minimize the amount of nix code you need to add.
16For the documentation, see https://input-output-hk.github.io/haskell.nix/.
18** Quickstart
20For =cabal.project= project add a =default.nix=:
22#+begin_src sh
23{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
24, haskellCompiler ? "ghc865"
25}:
26 pkgs.haskell-nix.cabalProject {
27 src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
28 ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${haskellCompiler};
29 }
30#+end_src
32Note that you'll need to add a comment specifying the expected sha256
33output for your =source-repository-packages= in your =cabal.project=
34file:
36#+begin_src sh
37source-repository-package
38 type: git
39 location: https://github.com/input-output-hk/iohk-monitoring-framework
40 subdir: plugins/backend-editor
41 tag: 4956b32f039579a0e7e4fd10793f65b4c77d9044
42 --sha256: 03lyb2m4i6p7rpjqarnhsx21nx48fwk6rzsrx15k6274a4bv0pix
43#+end_src
45For a =stack.yaml= project add a =default.nix=:
47#+begin_src sh
48{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
49}:
50 pkgs.haskell-nix.stackProject {
51 src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
52 }
53#+end_src
55To build the library component of a package in the project run:
57#+begin_src sh
58nix build -f . your-package-name.components.library
59#+end_src
61To build an executable:
63#+begin_src sh
64nix build -f . your-package-name.components.exes.your-exe-name
65#+end_src
67To open a shell for use with `cabal` run:
69#+begin_src sh
70nix-shell -A shellFor
71cabal new-build your-package-name
72cabal new-repl your-package-name:library:your-package-name
73#+end_src
75** Cache
77CI pushes to [[https://cachix.org][cachix]] so you can benefit from the cache
78if you pin a combination of =haskell.nix= and =nixpkgs= built by CI.
80You'll need to configure the [[https://nix-tools.cachix.org][nix-tools cachix]]
81as a =substituter= for =nix= and add the public key found at the url to
82=trusted-public-keys=.
84** Related repos
86The =haskell.nix= repository contains the runtime system for building
87Haskell packages in Nix. It depends on other repos, which are:
89- [[https://github.com/input-output-hk/nix-tools][nix-tools]] — provides the programs for generating Nix expressions from
90 Haskell projects.
92- [[https://github.com/input-output-hk/hackage.nix][hackage.nix]] — the latest contents of the [[https://hackage.haskell.org/][Hackage]] databases,
93 converted to Nix expressions.
95- [[https://github.com/input-output-hk/stackage.nix][stackage.nix]] — all of the [[https://www.stackage.org/][Stackage]] snapshots, converted to Nix
96 expressions.
98** IRC Channel
100Join the [[https://www.irccloud.com/invite?channel=%23haskell.nix&hostname=irc.freenode.net&port=6697&ssl=1][#haskell.nix]] channel on [[https://freenode.net/][irc.freenode.net]] to get help or discuss
101the development of =haskell.nix= and =nix-tools=.