@@ -1,8 +1,9 @@
11# Getting started
22
3−`haskell.nix` can automatically translate your Cabal or Stack project and its dependencies into Nix code.
4−
5−This tutorial will teach you how to setup your project
3+`haskell.nix` can automatically translate your
4+[Cabal](https://cabal.readthedocs.io/en/latest/cabal-project.html)
5+or [Stack](https://docs.haskellstack.org/en/stable/README/#quick-start-guide)
6+project and its dependencies into Nix code.
67
78Assuming you have [Nix installed](https://nixos.org/download.html), you can start setting up your project.
89
@@ -13,7 +14,12 @@ so you can benefit from the binary cache built by CI:
1314
1415```bash
1516$ nix-env -iA cachix -f https://cachix.org/api/v1/install
17+installing 'cachix-0.3.8'
18+building '/nix/store/bh176xhpk4wrjm56iahm86wf85jaz23v-user-environment.drv'...
19+created 42 symlinks in user environment
20+
1621$ cachix use iohk
22+Configured https://iohk.cachix.org binary cache in ~/.config/nix/nix.conf
1723```
1824
1925## Scaffolding
@@ -24,13 +30,8 @@ projects.
2430Add `default.nix`:
2531
2632```nix
27−{ # Default version of GHC to use (when not otherwise specified)
28− defaultCompilerNixName ? "ghc865"
29−
30−# Fetch the latest haskell.nix and import its default.nix
31−, haskellNix ? import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {
32− inherit defaultCompilerNixName;
33−}
33+{ # Fetch the latest haskell.nix and import its default.nix
34+ haskellNix ? import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz") {}
3435
3536# haskell.nix provides access to the nixpkgs pins which are used by our CI, hence
3637# you will be more likely to get cache hits when using these.
@@ -52,19 +53,6 @@ Add `default.nix`:
5253}
5354```
5455
55−Or a shorter `default.nix` that uses the default nixpkgs and default GHC:
56−
57−```nix
58−{ haskellNix ? import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}
59−, pkgs ? haskellNix.pkgs
60−}: pkgs.haskell-nix.project {
61− src = pkgs.haskell-nix.haskellLib.cleanGit {
62− name = "haskell-nix-project";
63− src = ./.;
64− };
65−}
66−```
67−
6856!!! note "git dependencies"
6957 If you have git dependencies in your project, you'll need
7058 to [calculate sha256 hashes for them](./source-repository-hashes.md).
@@ -106,42 +94,20 @@ However, in your own project, you may wish to pin [Haskell.nix][] (as
10694you would pin Nixpkgs). This will make your builds reproducible, more
10795predictable, and faster (because the fixed version is cached).
10896
109−One way of doing this is to use `nix-prefetch-git` to get a JSON file
110−with a revision and SHA-256 hash of [Haskell.nix][].
111−
112−```
113−$ nix-prefetch-git --quiet https://github.com/input-output-hk/haskell.nix | tee haskell-nix-src.json
114−{
115− "url": "https://github.com/input-output-hk/haskell.nix",
116− "rev": "f1a94a4c82a2ab999a67c3b84269da78d89f0075",
117− "date": "2019-06-05T01:06:12+00:00",
118− "sha256": "0ggxsppjlb6q6a83y12cwgrdnqnw1s128rpibgzs5p1966bdfqla",
119− "fetchSubmodules": false
120−}
121−```
122−
123−(The `tee` command is just to show you the result.)
124−Use the following expression to import that version:
97+Straightforward way of doing this is to change branch name to a revision.
12598
12699```nix
127−{ nixpkgs ? <nixpkgs> }:
100+{ # Fetch the latest haskell.nix and import its default.nix
101+ haskellNix ? import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/f1a94a4c82a2ab999a67c3b84269da78d89f0075.tar.gz") {}
128102
129−let
130− spec = builtins.fromJSON (builtins.readFile ./haskell-nix-src.json);
131− haskell-nix-src = (import nixpkgs {}).fetchgit {
132− name = "haskell-lib";
133− inherit (spec) url rev sha256 fetchSubmodules;
134− };
135−in
136− import nixpkgs (import haskell-nix-src)
103+...
137104```
138105
139106There are other possible schemes for pinning. See
140−[`haskell.nix/lib/fetch-external.nix`](https://github.com/input-output-hk/haskell.nix/blob/master/lib/fetch-external.nix),
141−the [niv](https://github.com/nmattia/niv) tool, or the Nix Flakes
142−proposal.
107+[Bumping Hackage and Stackage snapshots](./hackage-stackage.md) and
108+[Nix tutorial on reproducibility using pinning](https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html).
143109
144−# Going forward
110+## Going forward
145111
146112There are a number of things to explore further in the tutorials section.
147113