forked from seanhess/web-view
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add nix flake, GitHub Actions workflow, fix tests
* Add Nix flake configuration for building and development - Configure build inputs and overlays - Set up development shells for main package and example * Add GitHub Actions workflow for CI - Build packages and devShells on Ubuntu and macOS - Use DeterminateSystems' Nix installer and cache actions - Adds cabal.project file for `cabal test` * Update documentation - Add Local Development section with Nix instructions - Document dev shell and example project setup - Include example usage of flake overlay * cabal changes file - Add missing test resource files to extra-source-files - removed build-tool-depend since cabal does not see skeletest-preprocessor provided by nix * Fix CSS rendering for golden tests - There were two extra spaces before each CSS Node and an extra newline before and after the CSS attributes. notes: - the hlint and fourmolu pre-commit checks are dissabled, since they need to be applied across the codebase - the hpack pre-commit check is dissabled because the version is 0.36.1 instead of 0.37.0
- Loading branch information
Showing
11 changed files
with
387 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Haskell CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Nix | ||
uses: DeterminateSystems/nix-installer-action@main | ||
|
||
- name: Setup Nix cache | ||
uses: DeterminateSystems/magic-nix-cache-action@main | ||
|
||
- name: Check packages | ||
run: | | ||
nix flake check | ||
- name: Build packages | ||
run: | | ||
# Build all packages for the current system | ||
nix build .# | ||
nix build .#web-view | ||
- name: Build devShells | ||
run: | | ||
# Build all devShells for the current system | ||
nix develop .#web-view -c cabal test | ||
cd example | ||
nix develop ..#example -c cabal build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ dist | |
tags | ||
docs/old.md | ||
build | ||
|
||
.direnv | ||
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nix/store/kfqz1dbhi2pvni8p8bxpjx89gyvjxl8b-pre-commit-config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
tests: True | ||
packages: | ||
. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
description = "web-view"; | ||
|
||
inputs = { | ||
git-hooks = { | ||
url = "github:cachix/git-hooks.nix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | ||
nix-filter.url = "github:numtide/nix-filter/main"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = | ||
inputs@{ self | ||
, flake-utils | ||
, nix-filter | ||
, git-hooks | ||
, ... | ||
}: | ||
let | ||
web-view-src = nix-filter.lib { | ||
root = ./.; | ||
include = [ | ||
(nix-filter.lib.inDirectory "src") | ||
(nix-filter.lib.inDirectory "embed") | ||
(nix-filter.lib.inDirectory "test") | ||
./README.md | ||
./CHANGELOG.md | ||
./LICENSE | ||
./web-view.cabal | ||
./cabal.project | ||
./package.yaml | ||
./fourmolu.yaml | ||
]; | ||
}; | ||
|
||
overlay = final: prev: { | ||
haskell = prev.haskell // { | ||
packageOverrides = prev.lib.composeExtensions prev.haskell.packageOverrides (hfinal: hprev: { | ||
web-view = hfinal.callCabal2nix "web-view" web-view-src { }; | ||
}); | ||
}; | ||
}; | ||
in | ||
{ | ||
overlays.default = overlay; | ||
} | ||
// flake-utils.lib.eachDefaultSystem ( | ||
system: | ||
let | ||
pkgs = import inputs.nixpkgs { | ||
inherit system; | ||
overlays = [ overlay ]; | ||
}; | ||
|
||
example-src = nix-filter.lib { | ||
root = ./example; | ||
include = [ | ||
(nix-filter.lib.inDirectory "app") | ||
./example/example.cabal | ||
./example/cabal.project | ||
]; | ||
}; | ||
|
||
myHaskellPackages = pkgs.haskellPackages.extend ( | ||
hfinal: hprev: { | ||
attoparsec-aeson = hfinal.callHackage "attoparsec-aeson" "2.2.0.0" { }; | ||
skeletest = hprev.skeletest.overrideAttrs (old: { | ||
meta = old.meta // { broken = false; }; | ||
}); | ||
Diff = hfinal.callHackage "Diff" "0.5" { }; | ||
aeson = hfinal.callHackage "aeson" "2.2.2.0" { }; | ||
} | ||
); | ||
|
||
shellCommon = { | ||
inherit (self.checks.${system}.pre-commit-check) shellHook; | ||
# don't use the modified package set to build dev tools | ||
buildInputs = with pkgs.haskellPackages; [ | ||
cabal-install | ||
haskell-language-server | ||
fast-tags | ||
ghcid | ||
fourmolu | ||
pkgs.hpack | ||
]; | ||
withHoogle = true; | ||
doBenchmark = true; | ||
CABAL_CONFIG = "/dev/null"; | ||
}; | ||
in | ||
{ | ||
checks = { | ||
hyperbole-check = self.packages.${system}.web-view; | ||
pre-commit-check = git-hooks.lib.${system}.run { | ||
src = web-view-src; | ||
hooks = { | ||
# hlint.enable = true; | ||
# hpack.enable = true; | ||
# fourmolu.enable = true; | ||
nixpkgs-fmt.enable = true; | ||
}; | ||
}; | ||
}; | ||
|
||
packages = { | ||
default = self.packages.${system}.web-view; | ||
web-view = myHaskellPackages.web-view; | ||
}; | ||
inherit pkgs; | ||
|
||
devShells = { | ||
default = self.devShells.${system}.web-view; | ||
web-view = myHaskellPackages.shellFor ( | ||
shellCommon // { packages = p: [ p.web-view ]; } | ||
); | ||
example = myHaskellPackages.shellFor ( | ||
shellCommon | ||
// { | ||
packages = _: [ | ||
(myHaskellPackages.callCabal2nix "example" example-src { }) | ||
]; | ||
} | ||
); | ||
}; | ||
} | ||
); | ||
} |
Oops, something went wrong.