Expose two templates: default and example (#69)

Co-authored-by: Sridhar Ratnakumar <srid@srid.ca>
This commit is contained in:
Shivaraj B H 2023-02-10 07:46:59 +05:30 committed by GitHub
parent 7019678d8c
commit 3a515400fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 9 deletions

View File

@ -14,17 +14,30 @@ jobs:
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Test template
- name: Test flake templates
id: template
run: |
FLAKE=$(pwd)
TEMP_DIR=$(mktemp -d)
cd $TEMP_DIR
function templateTest () {
# Build haskell executable
nix build --override-input haskell-flake path:${FLAKE}
# Test haskell devshell (via HLS check)
nix develop --override-input haskell-flake path:${FLAKE} -c haskell-language-server
}
set -x
#### Test "#example" template
nix flake init -t $FLAKE#example
templateTest
### Test "#default" template
rm -f flake.nix
nix flake init -t $FLAKE
# Build haskell executable
nix build --override-input haskell-flake path:${FLAKE}
# Test haskell devshell (via HLS check)
nix develop --override-input haskell-flake path:${FLAKE} -c haskell-language-server
templateTest
- name: Run test
id: test
run: ./runtest.sh

View File

@ -5,6 +5,7 @@
- New features
- #63: Add `config.haskellProjects.${name}.outputs` containing all flake outputs for that project.
- #49: The `packages` option now autodiscovers the top-level `.cabal` file as its default value.
- #69: The default flake template creates `flake.nix` only, while the `#example` one creates the full Haskell project template.
- API changes
- #37: Group `buildTools` (renamed to `tools`), `hlsCheck` and `hlintCheck` under the `devShell` submodule option; and allow disabling them all using `devShell.enable = false;` (useful if you want haskell-flake to produce just the package outputs).
- #64: Remove hlintCheck (use [treefmt-nix](https://github.com/numtide/treefmt-nix#flake-parts) instead)

View File

@ -8,17 +8,21 @@ To keep `flake.nix` smaller (see examples below) and declarative ([what](https:/
## Usage
To use `haskell-flake` in your Haskell projects, run:
To use `haskell-flake` in your *existing* Haskell projects, run:
``` nix
nix flake init -t github:srid/haskell-flake
```
This will generate a template Haskell project with a `flake.nix`. If you already have a Haskell project, copy over this `flake.nix` and adjust accordingly.
To create a *new* Haskell project, run:
``` nix
nix flake init -t github:srid/haskell-flake#example
```
### Template
If you are bootstrapping a *new* Haskell project, you may use https://github.com/srid/haskell-template which already uses `haskell-flake` along with other opinionated defaults.
You may also use https://github.com/srid/haskell-template which already uses `haskell-flake` along with other opinionated defaults.
## Documentation

View File

@ -3,7 +3,11 @@
outputs = { self, ... }: {
flakeModule = ./flake-module.nix;
templates.default = {
description = "Example project using haskell-flake";
description = "A simple flake.nix using haskell-flake";
path = builtins.path { path = ./example; filter = path: _: baseNameOf path == "flake.nix"; };
};
templates.example = {
description = "Example Haskell project using haskell-flake";
path = ./example;
};
};