on iko/ghcjs-patch-master help sign in
Add project, cabalProject, stackProject references (#753)

* Add project, cabalProject, stackProject references * Update docs/reference/library.md Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com> Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>

commit33445e4fb94281e7e3f2fae15586590e1a42e154 authorDomen Kožar <domen@dev.si> dateWed 8 Jul 2020, 11:25 (6 years ago) parent4be762d
2 files changed+62−2
docs/reference/library.md+60−2 docs/tutorials/getting-started.md+2
docs/reference/library.md+60−2
@@ -4,11 +4,11 @@ what you get when importing [Haskell.nix][]. It might be helpful to
44load the library in the [Nix REPL](../tutorials/development.md#using-nix-repl) to
55test things.
66
7− * [Types](#types) — the kinds of data that you will encounter working with [Haskell.nix][].
7+ * [Data structures](#data-structures) — the kinds of data that you will encounter working with [Haskell.nix][].
88 * [Top-level attributes](#top-level-attributes) — Functions and derivations defined in the Haskell.nix attrset.
99 * [Package-set functions](#package-set-functions) — Helper functions defined on the `hsPkgs` package set.
1010
11−# Types
11+# Data structures
1212
1313## Package Set
1414
@@ -116,6 +116,64 @@ will be passed to it:
116116
117117# Top-level attributes
118118
119+## project
120+
121+Function that accepts attribute set with a `src` attribute and looks for `stack.yaml` file relative to it.
122+
123+If file exists, it calls [stackProject](#stack-project) function. Otherwise it will call [cabalProject](#cabal-project) function.
124+
125+**Example**:
126+
127+```nix
128+pkgs.haskell-nix.project {
129+ # 'cleanGit' cleans a source directory based on the files known by git
130+ src = pkgs.haskell-nix.haskellLib.cleanGit {
131+ name = "haskell-nix-project";
132+ src = ./.;
133+ };
134+}
135+```
136+
137+## stackProject
138+
139+A function calling [callStackToNix](#callStackToNix) with all arguments.
140+
141+Then feeding its result into [mkStackPkgSet](#mkStackPkgSet) passing also
142+`pkg-def-extras` and `modules` arguments.
143+
144+**Return value**:
145+
146+| Attribute | Type | Description |
147+|-------------------|--------------------------------------------------|----------------------------------------------------------------------------|
148+| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
149+| `pkg-set` | Attrset | [`pkgSet`](#package-set) |
150+| `stack-nix` | | `projectNix` attribute of [`callStackToNix`](#callStackToNix) return value |
151+| `shellFor` | Function | [`shellFor`](#shellFor) |
152+| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcWithHoogle) |
153+| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcWithPackages) |
154+
155+
156+## cabalProject
157+
158+A function calling [callCabalProjectToNix](#callCabalProjectToNix) with all arguments.
159+
160+Then feeding its result into [mkStackPkgSet](#mkStackPkgSet) passing also
161+`pkg-def-extras`, `extra-hackages` and `modules` arguments.
162+
163+**Return value**:
164+
165+| Attribute | Type | Description |
166+|-------------------|--------------------------------------------------|-----------------------------------------------------------------------------|
167+| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
168+| `pkg-set` | Attrset | [`pkgSet`](#package-set) |
169+| `plan-nix` | | `projectNix` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
170+| `index-state` | | `index-state` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
171+| `shellFor` | Function | [`shellFor`](#shellfor) |
172+| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
173+| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |
174+
175+
176+
119177## mkStackPkgSet
120178
121179Creates a [package set](#package-set) based on the `pkgs.nix` output
docs/tutorials/getting-started.md+2
@@ -111,6 +111,8 @@ There are other possible schemes for pinning. See
111111
112112## Going forward
113113
114+Read through [project](../reference/library.md#project) function reference to see how the API works.
115+
114116There are a number of things to explore further in the tutorials section.
115117
116118[haskell.nix]: https://github.com/input-output-hk/haskell.nix