Skip to content

Commit c08ff94

Browse files
authored
Add basic haskell-nix setup (#544)
* Add basic haskell-nix setup * Add suggested feedback * Add setup to main page & document nix flake
1 parent 4b3eee8 commit c08ff94

File tree

5 files changed

+294
-0
lines changed

5 files changed

+294
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.direnv
2+
result*
3+
dist-newstyle
4+
.pre-commit-config.yaml

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,19 @@ but will appear before examples with a greater order.
182182

183183
## Reference: Technology choices
184184

185+
### JS
186+
185187
The website generated by `message-index` uses a few JS components.
186188

187189
- [highlight.js](https://highlightjs.org/) for highlighting blocks of code. [License: BSD 3-Clause](https://github.com/highlightjs/highlight.js/blob/main/LICENSE).
188190
- [TableFilter](http://www.tablefilter.com/) for the filtering functionality in the error message table. [License: MIT](https://github.com/koalyptus/TableFilter/blob/master/LICENSE).
189191

192+
### Nix flake
193+
194+
The Nix flake uses [flake-parts](https://flake.parts/), as well as the flake-parts modules for
195+
- [haskell-flake](https://github.com/srid/haskell-flake) ([haskell-flake flake-parts module](https://flake.parts/options/haskell-flake))
196+
- [devshell](https://github.com/numtide/devshell) ([devshell flake-parts module](https://flake.parts/options/devshell))
197+
190198
Generally speaking, we choose technology for this site based on the following criteria:
191199

192200
* The build process for the site should be simple, relying on no build tools or package managers aside from `cabal` or `stack`

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,51 @@ Today, the Haskell Message Index supports three tools. Any user-facing Haskell-r
1616
| GHCup | 0.1.19.0 | `GHCup-` | [/ghcup](https://errors.haskell.org/ghcup) |
1717
| Cabal | 3.12 | `Cabal-` | [/cabal](https://errors.haskell.org/cabal) |
1818

19+
## Setup
20+
21+
This site is built with [Haskell](https://haskell.org) using the static-site generator [Hakyll](https://jaspervdj.be/hakyll/).
22+
23+
### 'Normal' Install
24+
25+
To run the site locally, you need to
26+
0. [install Haskell & Cabal](https://www.haskell.org/ghcup/):
27+
```shell
28+
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
29+
```
30+
1. Clone the Repo
31+
```shell
32+
git clone https://github.com/haskellfoundation/error-message-index.git
33+
```
34+
2. Run it
35+
```shell
36+
cd error-message-index # yes,
37+
cd message-index # both of those are needed
38+
cabal update
39+
cabal run -- site watch # Starts a web server on http://localhost:8000
40+
```
41+
42+
### with Nix
43+
44+
To run the site with Nix, you need to have [Nix](https://nixos.org/) installed. You can install it via the [Determinate Systems installer](https://zero-to-nix.com/start/install):
45+
```shell
46+
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
47+
```
48+
1. Clone the Repo
49+
```shell
50+
git clone https://github.com/haskellfoundation/error-message-index.git
51+
```
52+
2. Run it
53+
```shell
54+
cd error-message-index # yes,
55+
cd message-index # both of those are needed
56+
nix develop
57+
cabal run -- site watch # Starts a web server on http://localhost:8000
58+
```
59+
60+
For more on the Nix flake, have a look [here](./CONTRIBUTING.md#nix-flake).
61+
62+
And now, since you're up and running, you can start [contributing](./CONTRIBUTING.md)! :)
63+
1964
## Contributing to the Message Index
2065

2166
Contributions may come in the form of changes to the code base, as well as opening or commenting on issues and pull requests. You are warmly invited to participate!

flake.lock

Lines changed: 186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
nixConfig.allow-import-from-derivation = true;
3+
inputs = {
4+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
5+
parts.url = "github:hercules-ci/flake-parts";
6+
haskell-flake.url = "github:srid/haskell-flake";
7+
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
8+
devshell.url = "github:numtide/devshell";
9+
devshell.inputs.nixpkgs.follows = "nixpkgs";
10+
};
11+
outputs = inputs:
12+
inputs.parts.lib.mkFlake {inherit inputs;} {
13+
systems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
14+
imports = [
15+
inputs.devshell.flakeModule
16+
inputs.haskell-flake.flakeModule
17+
inputs.pre-commit-hooks.flakeModule
18+
];
19+
20+
perSystem = {
21+
config,
22+
pkgs,
23+
...
24+
}: {
25+
devshells.default = {
26+
devshell = {
27+
packagesFrom = [config.devShells.ghc96];
28+
packages = [];
29+
startup = {
30+
pre-commit.text = config.pre-commit.installationScript;
31+
};
32+
};
33+
};
34+
pre-commit = {
35+
check.enable = true;
36+
settings.hooks = {
37+
cabal-fmt.enable = true;
38+
hlint.enable = true;
39+
ormolu.enable = true;
40+
41+
alejandra.enable = true;
42+
deadnix.enable = true;
43+
};
44+
};
45+
haskellProjects.ghc96 = {
46+
basePackages = pkgs.haskell.packages.ghc96;
47+
projectRoot = ./message-index;
48+
};
49+
};
50+
};
51+
}

0 commit comments

Comments
 (0)