mirror of
https://github.com/srid/haskell-flake.git
synced 2024-09-11 05:55:25 +03:00
Expose two templates: default
and example
(#69)
Co-authored-by: Sridhar Ratnakumar <srid@srid.ca>
This commit is contained in:
parent
7019678d8c
commit
3a515400fd
23
.github/workflows/ci.yaml
vendored
23
.github/workflows/ci.yaml
vendored
@ -14,17 +14,30 @@ jobs:
|
|||||||
extra_nix_config: |
|
extra_nix_config: |
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command flakes
|
||||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Test template
|
- name: Test flake templates
|
||||||
id: template
|
id: template
|
||||||
run: |
|
run: |
|
||||||
FLAKE=$(pwd)
|
FLAKE=$(pwd)
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
cd $TEMP_DIR
|
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
|
nix flake init -t $FLAKE
|
||||||
# Build haskell executable
|
templateTest
|
||||||
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
|
|
||||||
- name: Run test
|
- name: Run test
|
||||||
id: test
|
id: test
|
||||||
run: ./runtest.sh
|
run: ./runtest.sh
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
- New features
|
- New features
|
||||||
- #63: Add `config.haskellProjects.${name}.outputs` containing all flake outputs for that project.
|
- #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.
|
- #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
|
- 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).
|
- #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)
|
- #64: Remove hlintCheck (use [treefmt-nix](https://github.com/numtide/treefmt-nix#flake-parts) instead)
|
||||||
|
10
README.md
10
README.md
@ -8,17 +8,21 @@ To keep `flake.nix` smaller (see examples below) and declarative ([what](https:/
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To use `haskell-flake` in your Haskell projects, run:
|
To use `haskell-flake` in your *existing* Haskell projects, run:
|
||||||
|
|
||||||
``` nix
|
``` nix
|
||||||
nix flake init -t github:srid/haskell-flake
|
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
|
### 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
|
## Documentation
|
||||||
|
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
outputs = { self, ... }: {
|
outputs = { self, ... }: {
|
||||||
flakeModule = ./flake-module.nix;
|
flakeModule = ./flake-module.nix;
|
||||||
templates.default = {
|
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;
|
path = ./example;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user