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: README.md
+22-12Lines changed: 22 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,15 @@ This is an example Haskell project using Nix to setup a development environment.
4
4
5
5
This uses Nix and Cabal without Stack. This is because when using Nix, you don't need Stack, as Nix provides harmonious snapshots of Haskell packages. However Stack users can still develop on this project, they just have to generate an appropriate `stack.yaml` from the Cabal file.
6
6
7
-
The first step is that we have to acquire `cabal2nix`, which we use to generate a `cabal.nix` file from the `package.yaml`. Our custom `default.nix` then imports the `cabal.nix` and adds extra custom build steps like encoding environment variables.
7
+
The first step is that we have to acquire `cabal2nix`, which we use to generate a `cabal.nix` file from the `package.yaml`.
8
+
9
+
We also write a custom `default.nix` then imports the `cabal.nix` and adds extra custom build steps like encoding environment variables.
10
+
11
+
Both the `cabal.nix` and `default.nix` remain as Haskell `callPackage` derivations.
12
+
13
+
This means the function parameter names may conflict with non-Haskell package names.
14
+
15
+
If you get a conflict, make sure to do explicit overrides when using `callPackage`.
8
16
9
17
Note that the usage of `package.yaml` means we are using the [hpack format](https://github.com/sol/hpack). This format is transformed to a cabal file via the `hpack` command.
10
18
@@ -118,34 +126,36 @@ Remember that Haskell package versions conventionally use `Major.Major.Minor.Pat
118
126
119
127
## Non-Haskell Dependencies
120
128
121
-
For non-Haskell dependencies that are CLI executables, if you want them to be made available to the build and final output, you need to add these dependencies to:
129
+
For non-Haskell dependencies that are CLI executables, add them to:
122
130
123
131
```yaml
124
132
system-build-tools:
125
133
- hello
126
134
```
127
135
128
-
This will put it into the generated `cabal.nix` as a function parameter.
129
-
130
-
To ensure that these dependency names do not conflict with Haskell dependencies with the same name, it's important to specify them when using the `callPackage`.
136
+
They will be available during `nix-build` and `nix-shell`.
For them to be available for the output, you must use `makeWrapper`.
135
139
136
-
For non-Haskell dependencies that are compiled libraries that are expected to be linked against, you need to add these dependencies to:
140
+
For non-Haskell dependencies that are linkable libraries, add them to:
137
141
138
142
```yaml
139
143
extra-libraries:
140
144
- mnl
141
145
```
142
146
143
-
These C libraries will be made available to `nix-build` and `nix-shell`. The `cabal configure` will automatically find them and link them during compilation.
147
+
The name of these libraries is the suffix of the C linking option `-lmnl` giving you `mnl`.
148
+
149
+
They will be will available to `nix-build` and `nix-shell`. The `cabal configure` will automatically find them and link them during compilation.
150
+
151
+
Sometimes these non-Haskell dependencies have names that conflict with Haskell dependencies of the same name.
152
+
153
+
To resolve this, override explicitly when using `callPackage`. This is done in both `shell.nix` and `release.nix`.
144
154
145
-
However in Nixpkgs, these libraries will have different names. You should then explicitly specify them when using the `callPackage`:
0 commit comments