Skip to content

Add project, cabalProject, stackProject references #753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions docs/reference/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ what you get when importing [Haskell.nix][]. It might be helpful to
load the library in the [Nix REPL](../tutorials/development.md#using-nix-repl) to
test things.

* [Types](#types) — the kinds of data that you will encounter working with [Haskell.nix][].
* [Data structures](#data-structures) — the kinds of data that you will encounter working with [Haskell.nix][].
* [Top-level attributes](#top-level-attributes) — Functions and derivations defined in the Haskell.nix attrset.
* [Package-set functions](#package-set-functions) — Helper functions defined on the `hsPkgs` package set.

# Types
# Data structures

## Package Set

Expand Down Expand Up @@ -116,6 +116,64 @@ will be passed to it:

# Top-level attributes

## project

Function that accepts attribute set with a `src` attribute and looks for `stack.yaml` file relative to it.

If file exists, it calls [stackProject](#stack-project) function. Otherwise it will call [cabalProject](#cabal-project) function.

**Example**:

```nix
pkgs.haskell-nix.project {
# 'cleanGit' cleans a source directory based on the files known by git
src = pkgs.haskell-nix.haskellLib.cleanGit {
name = "haskell-nix-project";
src = ./.;
};
}
```

## stackProject

A function calling [callStackToNix](#callStackToNix) with all arguments.

Then feeding its result into [mkStackPkgSet](#mkStackPkgSet) passing also
`pkg-def-extras` and `modules` arguments.

**Return value**:

| Attribute | Type | Description |
|-------------------|--------------------------------------------------|----------------------------------------------------------------------------|
| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
| `pkg-set` | Attrset | [`pkgSet`](#package-set) |
| `stack-nix` | | `projectNix` attribute of [`callStackToNix`](#callStackToNix) return value |
| `shellFor` | Function | [`shellFor`](#shellFor) |
| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcWithHoogle) |
| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcWithPackages) |


## cabalProject

A function calling [callCabalProjectToNix](#callCabalProjectToNix) with all arguments.

Then feeding its result into [mkStackPkgSet](#mkStackPkgSet) passing also
`pkg-def-extras`, `extra-hackages` and `modules` arguments.

**Return value**:

| Attribute | Type | Description |
|-------------------|--------------------------------------------------|-----------------------------------------------------------------------------|
| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
| `pkg-set` | Attrset | [`pkgSet`](#package-set) |
| `plan-nix` | | `projectNix` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
| `index-state` | | `index-state` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
| `shellFor` | Function | [`shellFor`](#shellfor) |
| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |



## mkStackPkgSet

Creates a [package set](#package-set) based on the `pkgs.nix` output
Expand Down
2 changes: 2 additions & 0 deletions docs/tutorials/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ There are other possible schemes for pinning. See

## Going forward

Read through [project](../reference/library.md#project) function reference to see how the API works.

There are a number of things to explore further in the tutorials section.

[haskell.nix]: https://github.com/input-output-hk/haskell.nix