summaryrefslogtreecommitdiff
path: root/web/tutorials/01-installation.markdown
blob: 16e73c8ba94c74da063ba3a6b51cba07c80b640d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
title: Installation
author: Jasper Van der Jeugt
type: main
---

Installation
------------

Installation is provided via Hackage, and some packages are available for
different distributions.  There are a few different methods to install
Hakyll.

1.  You can use [ghcup] to install Cabal and then use:

        $ cabal new-install hakyll

2.  Using [stack]:

        $ stack install hakyll

3.  There are also some Linux distro packages:

    - [Debian unstable](http://packages.debian.org/source/sid/haskell-hakyll)
    - [Fedora](https://apps.fedoraproject.org/packages/ghc-hakyll)
    - [Nix]: `$ nix-env -iA nixos.haskellPackages.hakyll`

[ghcup]: https://www.haskell.org/ghcup/
[Nix]: https://nixos.org/nixos/packages.html#hakyll
[stack]: http://www.haskellstack.org/

Building the example site
-------------------------

Apart from the main Hakyll library, the package also provides you with an
executable `hakyll-init` to create an example site.  This is an easy way to get
started.

Using cabal
===========

Create the example site:

    hakyll-init my-site

If `hakyll-init` is not found, make sure `~/.ghcup/env` is sourced.

In the `my-site` directory, you can use `cabal new-install` to install the
`site` executable (which builds your website).  Alternatively, you can just
use `cabal new-run site [command]`.

You can build the site using:

    my-site build

And preview (and build) it using:

    my-site watch

Using stack
===========

Create the `my-site` directory with the project files inside:

    $ stack exec hakyll-init my-site

Now, change into `my-site` directory and create a file `stack.yaml` here with
the following content:

    resolver: lts-14.16  # Adapt this as needed
    packages:
      - .
    extra-deps:
      - hakyll-4.13.0.1  # Or a later version you installed

On NixOS you will probably have to add the following lines to this file:

    nix:
      enable: true
      packages: [zlib.dev, zlib.out]

The file `site.hs` holds the configuration of your site, as an executable
haskell program. We can compile and run it like this:

    $ stack build
    $ stack exec site build

If you installed `hakyll` with a preview server (this is the default), you can
now use:

    $ stack exec site watch

and have a look at your site at
[http://localhost:8000/](http://localhost:8000/).