diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 126f59b..1891d58 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fb6cc2..4625452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index 6542ad0..7e33db5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/flake.nix b/flake.nix index c4bc81c..fb52e7d 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; };