on iko/ghcjs-patch-master help sign in
More documentation (#179)

* docs: Fix notes about .nix-tools.cache Relates to #57 * docs: Add note about Cabal 2.4 requirement Fixes #164 * docs: Autogenerate module option reference * docs: Update library reference * Buildkite: enable docs build on branches

commite15f235319ae867193a6f377084a9ca0eeb0b42f authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateSat 15 Jun 2019, 15:11 (7 years ago) parent7d94fe2
10 files changed+144−19
.buildkite/pipeline.yml−1 .gitignore+1 build.nix+13−1 docs/reference/commands.md+8−3 docs/reference/library.md+73−9 docs/reference/modules-preamble.md+10 docs/reference/modules.md−4 docs/user-guide/cabal-projects.md+4 scripts/options-doc.nix+29 scripts/update-docs.nix+6−1
.buildkite/pipeline.yml−1
@@ -15,6 +15,5 @@ steps:
1515 command:
1616 - nix-build build.nix -A maintainer-scripts.update-docs -o update-docs.sh
1717 - ./update-docs.sh
18− branches: master
1918 agents:
2019 system: x86_64-linux
.gitignore+1
@@ -1,5 +1,6 @@
11# The output of "mkdocs build"
22/site/
3+docs/reference/modules.md
34
45# Nix build results
56result*
build.nix+13−1
@@ -24,7 +24,19 @@ in {
2424 update-hackage = haskell.callPackage ./scripts/update-hackage.nix {};
2525 update-stackage = haskell.callPackage ./scripts/update-stackage.nix {};
2626 update-pins = haskell.callPackage ./scripts/update-pins.nix {};
27− update-docs = haskell.callPackage ./scripts/update-docs.nix {};
27+ update-docs = haskell.callPackage ./scripts/update-docs.nix {
28+ generatedOptions = import ./scripts/options-doc.nix {
29+ # nixpkgs unstable changes "Option has no description" from an
30+ # error into a warning. That is quite helpful when hardly any
31+ # of our options are documented, thanks @oxij.
32+ pkgs = import (pkgs.fetchFromGitHub {
33+ owner = "NixOS";
34+ repo = "nixpkgs";
35+ rev = "4ab1c14714fc97a27655f3a6877386da3cb237bc";
36+ sha256 = "16lcj9552q2jfxc27j6116qkf2vl2dcj7vhg5gdq4qi51d891yhn";
37+ }) {};
38+ };
39+ };
2840 check-hydra = haskell.callPackage ./scripts/check-hydra.nix {};
2941 };
3042}
docs/reference/commands.md+8−3
@@ -23,8 +23,10 @@ output directory, it will create a basic one with a
2323
2424!!! note
2525 If you find that there are missing files which should have been
26− generated, remove `.stack-to-nix.cache`. (There's an open issue for
27− this).
26+ generated, remove `.stack-to-nix.cache`
27+ (The open issue is [#57][cache-issue]).
28+
29+[cache-issue]: https://github.com/input-output-hk/haskell.nix/issues/57
2830
2931# plan-to-nix
3032
@@ -58,7 +60,10 @@ Inside the output directory, there will be another directory
5860generated by `cabal-to-nix`. The output file `pkgs.nix` refers to
5961these files.
6062
61−Same note as above applies about the cache file.
63+!!! note
64+ If you find that there are missing files which should have been
65+ generated, remove `.nix-tools.cache`
66+ (The open issue is [#57][cache-issue]).
6267
6368# cabal-to-nix
6469
docs/reference/library.md+73−9
@@ -42,18 +42,27 @@ system.
4242
4343## Haskell Package description
4444
45−Options for building a package. (todo: more info)
45+The _Haskell package descriptions_ are values of the
46+`pkgSet.config.packages` attrset. These are not derivations, but just
47+the configuration for building an individual package. The
48+configuration options are described under `packages.<name>` in [Module
49+options](./modules.md).
4650
4751## Component description
4852
49−Options for building a component. (todo: more info)
53+The _component descriptions_ are values of the
54+`pkgSet.config.packages.<package>.components` attrset. These are not
55+derivations, but just the configuration for building an individual
56+component. The configuration options are described under
57+`packages.<name>.components.*` in [Module options](./modules.md).
58+
5059
5160## Haskell Package
5261
53−A derivation which has a `components` attribute. This derivation is
54−actually just for the package `Setup.hs` script, and isn't very
55−interesting. To actually use the package, look within the components
56−structure.
62+In [Haskell.nix][], a _Haskell package_ is a derivation which has a
63+`components` attribute. This derivation is actually just for the
64+package `Setup.hs` script, and isn't very interesting. To actually use
65+the package, look within the components structure.
5766
5867```
5968components = {
@@ -67,14 +76,44 @@ components = {
6776
6877## Component
6978
79+In [Haskell.nix][], a _component_ is a derivation corresponding to a
80+[Cabal component](https://www.haskell.org/cabal/users-guide/developing-packages.html)
81+of a package.
82+
83+[Haskell.nix][] also defines a special `all` component, which is the
84+union of all components in the package.
85+
7086## Identifier
7187
7288A package identifier is an attrset pair of `name` and `version`.
7389
7490## Extras
7591
92+Extras allow adding more packages to the package set. These will be
93+functions taking a single parameter `hackage`. They should return an
94+attrset of package descriptions.
95+
7696## Modules
7797
98+Modules are the primary method of configuring building of the package
99+set. They are either:
100+
101+1. an attrset containing [option declarations](./options.md), or
102+2. a function that returns an attrset containing option declarations.
103+
104+If using the function form of a module, the following named parameters
105+will be passed to it:
106+
107+| Argument | Type | Description |
108+|------------------|------|---------------------|
109+| `haskellLib` | attrset | The [haskellLib](#haskelllib) utility functions. |
110+| `pkgs` | | The Nixpkgs collection. |
111+| `pkgconfPkgs` | | A mapping of cabal build-depends names to Nixpkgs packages. (TODO: more information about this) |
112+| `buildModules` | | |
113+| `config` | | |
114+| `options` | | |
115+
116+
78117# Top-level attributes
79118
80119## mkStackPkgSet
@@ -126,7 +165,11 @@ This is an attrset of `hsPkgs` packages from Stackage.
126165
127166## haskellPackages
128167
129−A `hsPkgs` package set
168+A `hsPkgs` package set, which is one of the recent LTS Haskell
169+releases from [`snapshots`](#snapshots).
170+
171+The chosen LTS is updated occasionally in [Haskell.nix][], though a
172+manual process.
130173
131174## nix-tools
132175
@@ -145,6 +188,10 @@ A derivation containing the `nix-tools` [command-line tools](commands.md).
145188
146189## haskellLib
147190
191+Assorted functions for operating on [Haskell.nix][] data. This is
192+distinct from `pkgs.haskell.lib` in the current Nixpkgs Haskell
193+Infrastructure.
194+
148195# Package-set functions
149196
150197These functions exist within the `hsPkgs` package set.
@@ -152,8 +199,8 @@ These functions exist within the `hsPkgs` package set.
152199## shellFor
153200
154201Create a `nix-shell` [development
155−environment](../user-guide/development.md) *for* developing one or
156−more packages.
202+environment](../user-guide/development.md) for developing one or more
203+packages.
157204
158205```
159206shellFor =
@@ -171,7 +218,24 @@ shellFor =
171218
172219## ghcWithPackages
173220
221+Creates a `nix-shell` [development
222+environment](../user-guide/development.md) including the given
223+packages selected from this package set.
224+
225+**Parameter**: a package selection function.
226+
227+**Return value**: a derivation
228+
229+**Example**:
230+
231+```
232+haskell.haskellPackages.ghcWithPackages (ps: with ps; [ lens conduit ])
233+```
234+
174235## ghcWithHoogle
175236
237+The same as `ghcWithPackages`, except, a `hoogle` command with a
238+Hoogle documentation index of the packages will be included in the
239+shell.
176240
177241[haskell.nix]: https://github.com/input-output-hk/haskell.nix
docs/reference/modules-preamble.mdnew file+10
@@ -0,0 +1,10 @@
1+Haskell.nix modules options for packages and components.
2+
3+!!! note "Undocumented"
4+ Please help write me.
5+
6+ This documentation is generated from Nix sources in the
7+ [`modules`](https://github.com/input-output-hk/haskell.nix/tree/master/modules)
8+ subdirectory.
9+
10+ The Markdown generation script could also be improved.
docs/reference/modules.mddeleted−4
@@ -1,4 +0,0 @@
1−Haskell.nix modules options for packages and components.
2−
3−!!! note "Undocumented"
4− Please help write me.
docs/user-guide/cabal-projects.md+4
@@ -14,6 +14,10 @@ about how to choose a specific compiler version.
1414
1515[compiler]: https://nixos.org/nixpkgs/manual/#how-to-install-a-compiler
1616
17+!!! note "Cabal version"
18+ The minimum Cabal version is 2.4. This version is available
19+ in the NixOS 19.03 release.
20+
1721For this example, we will run a `nix-shell` with the default GHC
1822version for Nixpkgs.
1923
scripts/options-doc.nixnew file+29
@@ -0,0 +1,29 @@
1+{ pkgs ? import <nixpkgs> {}
2+, lib ? pkgs.lib
3+}:
4+let
5+ # Provide a dummy pkg-def for the package set function
6+ pkg-def = hackage: {
7+ packages = {};
8+ compiler = {
9+ version = "";
10+ nix-name = "";
11+ packages = {};
12+ };
13+ };
14+
15+ # Apply the package set function to get NixOS options.
16+ inherit (import ../package-set.nix { hackage = null; inherit pkgs pkg-def; }) options;
17+
18+ # Use code from the NixOS manual to generate Docbook XML options list.
19+ manual = import (pkgs.path + /nixos/doc/manual) {
20+ inherit pkgs options;
21+ config.meta.doc = [];
22+ version = "testing";
23+ revision = "testing";
24+ };
25+in
26+ # Convert docbook options list to markdown
27+ pkgs.runCommand "options.md" {} ''
28+ ${pkgs.buildPackages.pandoc}/bin/pandoc -s -f docbook -t markdown_strict ${manual.generatedSources}/options-db.xml -o $out
29+ ''
scripts/update-docs.nix+6−1
@@ -1,4 +1,5 @@
1−{ stdenv, writeScript, coreutils, glibc, git, openssh, gnused, mkdocs }:
1+{ stdenv, writeScript, coreutils, glibc, git, openssh, gnused, mkdocs
2+, generatedOptions }:
23
34with stdenv.lib;
45
@@ -15,6 +16,9 @@ in
1516
1617 source ${./git.env}
1718
19+ echo "Preprocessing..."
20+ cat docs/reference/modules-preamble.md ${generatedOptions} > docs/reference/modules.md
21+
1822 echo "Building..."
1923 rm -rf site
2024 mkdocs build
@@ -23,6 +27,7 @@ in
2327 sed -i -e '/lastmod/d' site/sitemap.xml
2428 rm -f site/sitemap.xml.gz
2529 rev=$(git rev-parse --short HEAD)
30+ rm docs/reference/modules.md
2631
2732 echo "Updating git index..."
2833 git fetch origin