Skip to content

Commit

Permalink
Add basic haskell-nix setup (#544)
Browse files Browse the repository at this point in the history
* Add basic haskell-nix setup

* Add suggested feedback

* Add setup to main page & document nix flake
  • Loading branch information
haglobah authored Oct 13, 2024
1 parent 4b3eee8 commit c08ff94
Show file tree
Hide file tree
Showing 5 changed files with 294 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.direnv
result*
dist-newstyle
.pre-commit-config.yaml
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,19 @@ but will appear before examples with a greater order.

## Reference: Technology choices

### JS

The website generated by `message-index` uses a few JS components.

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

### Nix flake

The Nix flake uses [flake-parts](https://flake.parts/), as well as the flake-parts modules for
- [haskell-flake](https://github.com/srid/haskell-flake) ([haskell-flake flake-parts module](https://flake.parts/options/haskell-flake))
- [devshell](https://github.com/numtide/devshell) ([devshell flake-parts module](https://flake.parts/options/devshell))

Generally speaking, we choose technology for this site based on the following criteria:

* The build process for the site should be simple, relying on no build tools or package managers aside from `cabal` or `stack`
Expand Down
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,51 @@ Today, the Haskell Message Index supports three tools. Any user-facing Haskell-r
| GHCup | 0.1.19.0 | `GHCup-` | [/ghcup](https://errors.haskell.org/ghcup) |
| Cabal | 3.12 | `Cabal-` | [/cabal](https://errors.haskell.org/cabal) |

## Setup

This site is built with [Haskell](https://haskell.org) using the static-site generator [Hakyll](https://jaspervdj.be/hakyll/).

### 'Normal' Install

To run the site locally, you need to
0. [install Haskell & Cabal](https://www.haskell.org/ghcup/):
```shell
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
```
1. Clone the Repo
```shell
git clone https://github.com/haskellfoundation/error-message-index.git
```
2. Run it
```shell
cd error-message-index # yes,
cd message-index # both of those are needed
cabal update
cabal run -- site watch # Starts a web server on http://localhost:8000
```

### with Nix

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):
```shell
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
```
1. Clone the Repo
```shell
git clone https://github.com/haskellfoundation/error-message-index.git
```
2. Run it
```shell
cd error-message-index # yes,
cd message-index # both of those are needed
nix develop
cabal run -- site watch # Starts a web server on http://localhost:8000
```

For more on the Nix flake, have a look [here](./CONTRIBUTING.md#nix-flake).

And now, since you're up and running, you can start [contributing](./CONTRIBUTING.md)! :)

## Contributing to the Message Index

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!
Expand Down
186 changes: 186 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
nixConfig.allow-import-from-derivation = true;
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
devshell.url = "github:numtide/devshell";
devshell.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs:
inputs.parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
imports = [
inputs.devshell.flakeModule
inputs.haskell-flake.flakeModule
inputs.pre-commit-hooks.flakeModule
];

perSystem = {
config,
pkgs,
...
}: {
devshells.default = {
devshell = {
packagesFrom = [config.devShells.ghc96];
packages = [];
startup = {
pre-commit.text = config.pre-commit.installationScript;
};
};
};
pre-commit = {
check.enable = true;
settings.hooks = {
cabal-fmt.enable = true;
hlint.enable = true;
ormolu.enable = true;

alejandra.enable = true;
deadnix.enable = true;
};
};
haskellProjects.ghc96 = {
basePackages = pkgs.haskell.packages.ghc96;
projectRoot = ./message-index;
};
};
};
}

0 comments on commit c08ff94

Please sign in to comment.