You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/getting-started.md
+9-83Lines changed: 9 additions & 83 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ The first steps are to ensure you have [Nix](https://nixos.org/download.html) in
6
6
7
7
Then you have the choice to set-up your project using [the experimental Flake feature](#create-a-project-using-flakes) or [Niv](#create-a-project-using-niv), which are 2 ways to pin `nixpkgs` with Nix.
8
8
9
-
If you have an existing Haskell project that you want to build with `haskell.nix`. you might [prefer to use `hix`](#getting-started-with-hix).
9
+
If you have an existing Haskell project that you want to build with `haskell.nix`, you might [prefer to use `hix`](#getting-started-with-hix). `hix` is a more easy and user-friendly way to use `haskell.nix`, using it reduce considerably the size of the Nix expression you will have to maintain in your project codebase.
10
10
11
11
## Setting up the binary cache
12
12
@@ -46,7 +46,7 @@ This can be tricky to get setup properly. If you're still having trouble getting
46
46
47
47
## Create a project using Flakes
48
48
49
-
This section assumes you choose to uses the experimental flakes features, and so that you have added `experimental-features = [ "nix-command" "flakes" ];` in your Nix configuration. You can look at [the Uncyclo](https://nixos.wiki/wiki/Flakes) for more instructions. If you don't want to set up a Flakes project, [skip to the Niv section](#create-a-project-using-niv).
49
+
This section assumes you choose to uses the experimental flakes features, and so that you have added `experimental-features = [ "nix-command" "flakes" ];` in your Nix configuration. You can look at [the Uncyclo](https://nixos.wiki/wiki/Flakes) for more instructions.
50
50
51
51
The following `nix flake init` command creates a template `hello` package containing a `flake.nix` and `nix/hix.nix` file. The project can be used with
52
52
regular `nix` tools. This template is defined in the [NixOS/templates repository](https://github.com/NixOS/templates/tree/master/haskell.nix).
@@ -72,59 +72,14 @@ To build and run a component:
72
72
nix run .#hello:exe:hello
73
73
```
74
74
75
-
## Create a project using Niv
76
-
77
-
[Niv](https://github.com/nmattia/niv) is a command line tool for keeping track of Nix project dependencies. You don't need it if you [set up your project with Flakes](#create-a-project-using-flakes), and so you can skip this section.
78
-
79
-
This guide assumes that the `sources.haskellNix` will be set to point a pinned copy of the `haskell.nix` github repo. One easy way to do this is to use Niv. If you prefer not to use Niv another option is described in the in the following "[Using `haskell.nix` without Niv](#using-1-without-Niv)" section of this document.
80
-
81
-
After installing niv you can initialize niv and pin the latest `haskell.nix` commit by running the following in the root directory of the project:
82
-
```shell
83
-
niv init
84
-
niv add input-output-hk/haskell.nix -n haskellNix
85
-
```
86
-
87
-
Then when you want to update to the latest version of `haskellNix` use:
88
-
```shell
89
-
niv update haskellNix
90
-
```
91
-
92
-
### Using `haskell.nix` without Niv
93
-
94
-
If you would prefer not to use niv you can replace `sources = import ./nix/sources.nix {};` in the examples with:
The `fetchTarball` call above will always get the latest version, and is similar to an auto-updating Nix channel.
102
-
103
-
However, in your own project, you may wish to pin `haskell.nix` (as you would pin Nixpkgs). This will make your builds reproducible, more predictable, and faster (because the fixed version is cached).
104
-
105
-
Straightforward way of doing this is to change the branch name to a revision.
There are other possible schemes for pinning. See [Bumping Hackage and Stackage snapshots](./hackage-stackage.md) and [Nix tutorial on reproducibility using pinning](https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html).
113
-
114
75
## Scaffolding
115
76
116
77
The following code could be capy-pasted and will work with `stack.yaml` and `cabal.project` based projects.
117
78
118
-
For a Flakes-based project, use a `flake.nix`:
119
-
```nix
79
+
Edit your `flake.nix` as:```nix
120
80
{{#include getting-started-flakes/flake.nix}}
121
81
```
122
82
123
-
For a legacy (Nix) Nix project rather, use a `default.nix`:
124
-
```nix
125
-
{{#include getting-started/default.nix}}
126
-
```
127
-
128
83
> **Note:** Git dependencies
129
84
>
130
85
> If you have git dependencies in your project, you'll need to [calculate sha256 hashes for them](./source-repository-hashes.md).
@@ -136,32 +91,14 @@ Top-level attributes are Haskell packages (incl. dependencies) part of your proj
136
91
This section will show side by side the commands using Flakes experimental `new-command` API and legacy Nix commands.
137
92
138
93
To build the library component of a package in the project run:
0 commit comments