Skip to content

Commit 1e11332

Browse files
committed
Merge branch 'main' of github.com:seanhess/web-view
2 parents bf2d399 + ae82448 commit 1e11332

File tree

9 files changed

+401
-193
lines changed

9 files changed

+401
-193
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,32 @@ name: Haskell CI
22

33
on:
44
push:
5-
branches: [ "main" ]
65
pull_request:
7-
branches: [ "main" ]
6+
7+
permissions:
8+
contents: read
9+
packages: write # for cachix
810

911
jobs:
1012
build:
1113
strategy:
1214
matrix:
13-
os: [ubuntu-latest]
15+
os: [ubuntu-latest, macos-latest]
1416
runs-on: ${{ matrix.os }}
1517

1618
steps:
17-
- uses: actions/checkout@v3
18-
19-
- name: Install Nix
20-
uses: DeterminateSystems/nix-installer-action@main
21-
22-
- name: Setup Nix cache
23-
uses: DeterminateSystems/magic-nix-cache-action@main
19+
- uses: actions/checkout@v4
20+
21+
- uses: cachix/install-nix-action@v25
22+
with:
23+
nix_path: nixpkgs=channel:nixos-unstable
24+
25+
- uses: cachix/cachix-action@v14
26+
with:
27+
name: hyperbole
28+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
2429

2530
- name: Check packages
2631
run: |
2732
nix flake check
28-
# Build all devShells for the current system
29-
# FIXME figure out how to add this to: nix flake check
30-
# nix develop -c cabal test --dry-run
31-
# nix develop .#ghc982-web-view -c cabal test --dry-run
32-
# cd example
33-
# nix develop ..#ghc966-example -c cabal test --dry-run
34-
# nix develop ..#ghc982-example -c cabal test --dry-run
33+

README.md

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,26 +75,10 @@ el (width 100 . media (MinWidth 800) (width 400))
7575

7676
If you want to get a feel for web-view without cloning the project run `nix run github:seanhess/web-view` to run the example webserver locally
7777

78-
Local Development
79-
-----------------
80-
81-
### Nix
82-
83-
Prepend targets with ghc982 or ghc966 to use GHC 9.8.2 or GHC 9.6.6
84-
85-
- `nix run` starts the example project with GHC 9.8.2
86-
- `nix develop` to get a shell with all dependencies installed for GHC 9.8.2.
87-
- `nix develop .#ghc966-web-view` for GHC 9.6.6
88-
89-
You can also get a development shell for the example project with:
90-
91-
```
92-
cd example
93-
nix develop ../#ghc982-example
94-
cabal run
95-
```
78+
Import Flake
79+
------------
9680

97-
You can import this flake's overlay to add `web-view` to all package sets and override ghc966 and ghc982 with the packages to satisfy `web-view`'s dependencies.
81+
You can import this flake's overlay to add `web-view` to `overriddenHaskellPackages` and which provides a ghc966 and ghc982 package set that satisfy `web-view`'s dependencies.
9882

9983
```nix
10084
{
@@ -112,7 +96,7 @@ You can import this flake's overlay to add `web-view` to all package sets and ov
11296
inherit system;
11397
overlays = [ web-view.overlays.default ];
11498
};
115-
haskellPackagesOverride = pkgs.haskell.packages.ghc966.override (old: {
99+
haskellPackagesOverride = pkgs.overriddenHaskellPackages.ghc966.override (old: {
116100
overrides = pkgs.lib.composeExtensions (old.overrides or (_: _: { })) (hfinal: hprev: {
117101
# your overrides here
118102
});
@@ -127,6 +111,55 @@ You can import this flake's overlay to add `web-view` to all package sets and ov
127111
}
128112
```
129113

114+
Local Development
115+
-----------------
116+
117+
### Recommended ghcid command
118+
119+
If you want to work on both the web-view library and example code, this `ghcid` command will run and reload the examples server as you change any non-testing code.
120+
121+
```
122+
ghcid --command="cabal repl exe:example lib:web-view" --run=Main.main --warnings --reload=./embed/preflight.css
123+
```
124+
125+
If you want to work on the test suite, this will run the tests each time any library code is changed.
126+
127+
```
128+
ghcid --command="cabal repl test lib:web-view" --run=Main.main --warnings --reload=./embed/preflight.css
129+
```
130+
131+
### Nix
132+
133+
- `nix flake check` will build the library, example executable and devShell with ghc-9.8.2 and ghc-9.6.6
134+
- This is what the CI on GitHub runs
135+
- `nix run` or `nix run .#ghc982-example` to start the example project with GHC 9.8.2
136+
- `nix run .#ghc966-example` to start the example project with GHC 9.6.6
137+
- `nix develop` or `nix develop .#ghc982-shell` to get a shell with all dependencies installed for GHC 9.8.2.
138+
- `nix develop .#ghc966-shell` to get a shell with all dependencies installed for GHC 9.6.6.
139+
- `nix build`, `nix build .#ghc982-web-view` and `nix build .#ghc966-web-view` builds the library with the `overriddenHaskellPackages`
140+
- If you want to import this flake, use the overlay
141+
- `nix flake update nixpkgs` will update the Haskell package sets and development tools
142+
143+
### Common Nix Issues
144+
145+
#### Not Allowed to Refer to GHC
146+
147+
If you get an error like:
148+
149+
```
150+
error: output '/nix/store/64k8iw0ryz76qpijsnl9v87fb26v28z8-my-haskell-package-1.0.0.0' is not allowed to refer to the following paths:
151+
/nix/store/5q5s4a07gaz50h04zpfbda8xjs8wrnhg-ghc-9.6.3
152+
```
153+
154+
Follow these [instructions](https://nixos.org/manual/nixpkgs/unstable/#haskell-packaging-helpers)
155+
156+
#### Dependencies Incorrect
157+
158+
You will need to update the overlay, look for where it says `"${packageName}" = hfinal.callCabal2nix packageName src { };` and add a line like `Diff = hfinal.callHackage "Diff" "0.5" { };` with the package and version you need.
159+
160+
#### Missing Files
161+
162+
Check the `include` inside the `nix-filter.lib` to see if all files needed by cabal are there.
130163

131164
Learn More
132165
----------

Session.vim

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
let SessionLoad = 1
2+
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
3+
let v:this_session=expand("<sfile>:p")
4+
silent only
5+
silent tabonly
6+
cd ~/Projects/Work/GasWork/RelatedWork/web-view
7+
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
8+
let s:wipebuf = bufnr('%')
9+
endif
10+
let s:shortmess_save = &shortmess
11+
if &shortmess =~ 'A'
12+
set shortmess=aoOA
13+
else
14+
set shortmess=aoO
15+
endif
16+
badd +500 src/Web/View/Types.hs
17+
badd +277 src/Web/View/Style.hs
18+
badd +68 ~/.local/share/nvim/parrot/chats/2025-01-23.22-56-48.041.md
19+
badd +66 web-view.cabal
20+
badd +251 ~/.local/share/nvim/parrot/chats/2025-01-25.06-42-05.937.md
21+
badd +1 src/Web/View/Types
22+
argglobal
23+
%argdel
24+
$argadd src/Web/View/Types
25+
edit src/Web/View/Style.hs
26+
let s:save_splitbelow = &splitbelow
27+
let s:save_splitright = &splitright
28+
set splitbelow splitright
29+
wincmd _ | wincmd |
30+
vsplit
31+
1wincmd h
32+
wincmd _ | wincmd |
33+
split
34+
1wincmd k
35+
wincmd w
36+
wincmd w
37+
wincmd _ | wincmd |
38+
split
39+
1wincmd k
40+
wincmd w
41+
let &splitbelow = s:save_splitbelow
42+
let &splitright = s:save_splitright
43+
wincmd t
44+
let s:save_winminheight = &winminheight
45+
let s:save_winminwidth = &winminwidth
46+
set winminheight=0
47+
set winheight=1
48+
set winminwidth=0
49+
set winwidth=1
50+
exe '1resize ' . ((&lines * 38 + 39) / 79)
51+
exe 'vert 1resize ' . ((&columns * 91 + 91) / 182)
52+
exe '2resize ' . ((&lines * 38 + 39) / 79)
53+
exe 'vert 2resize ' . ((&columns * 91 + 91) / 182)
54+
exe '3resize ' . ((&lines * 38 + 39) / 79)
55+
exe 'vert 3resize ' . ((&columns * 90 + 91) / 182)
56+
exe '4resize ' . ((&lines * 38 + 39) / 79)
57+
exe 'vert 4resize ' . ((&columns * 90 + 91) / 182)
58+
argglobal
59+
balt src/Web/View/Types.hs
60+
setlocal fdm=manual
61+
setlocal fde=0
62+
setlocal fmr={{{,}}}
63+
setlocal fdi=#
64+
setlocal fdl=0
65+
setlocal fml=1
66+
setlocal fdn=20
67+
setlocal fen
68+
silent! normal! zE
69+
let &fdl = &fdl
70+
let s:l = 277 - ((18 * winheight(0) + 19) / 38)
71+
if s:l < 1 | let s:l = 1 | endif
72+
keepjumps exe s:l
73+
normal! zt
74+
keepjumps 277
75+
normal! 0
76+
lcd ~/Projects/Work/GasWork/RelatedWork/web-view
77+
wincmd w
78+
argglobal
79+
if bufexists(fnamemodify("~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Style.hs", ":p")) | buffer ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Style.hs | else | edit ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Style.hs | endif
80+
if &buftype ==# 'terminal'
81+
silent file ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Style.hs
82+
endif
83+
balt ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Types.hs
84+
setlocal fdm=manual
85+
setlocal fde=0
86+
setlocal fmr={{{,}}}
87+
setlocal fdi=#
88+
setlocal fdl=0
89+
setlocal fml=1
90+
setlocal fdn=20
91+
setlocal fen
92+
silent! normal! zE
93+
let &fdl = &fdl
94+
let s:l = 499 - ((30 * winheight(0) + 19) / 38)
95+
if s:l < 1 | let s:l = 1 | endif
96+
keepjumps exe s:l
97+
normal! zt
98+
keepjumps 499
99+
normal! 02|
100+
lcd ~/Projects/Work/GasWork/RelatedWork/web-view
101+
wincmd w
102+
argglobal
103+
if bufexists(fnamemodify("~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Types.hs", ":p")) | buffer ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Types.hs | else | edit ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Types.hs | endif
104+
if &buftype ==# 'terminal'
105+
silent file ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Types.hs
106+
endif
107+
balt ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Style.hs
108+
setlocal fdm=manual
109+
setlocal fde=0
110+
setlocal fmr={{{,}}}
111+
setlocal fdi=#
112+
setlocal fdl=0
113+
setlocal fml=1
114+
setlocal fdn=20
115+
setlocal nofen
116+
silent! normal! zE
117+
31,63fold
118+
87,112fold
119+
150,168fold
120+
276,279fold
121+
392,413fold
122+
442,470fold
123+
510,519fold
124+
let &fdl = &fdl
125+
let s:l = 125 - ((24 * winheight(0) + 19) / 38)
126+
if s:l < 1 | let s:l = 1 | endif
127+
keepjumps exe s:l
128+
normal! zt
129+
keepjumps 125
130+
normal! 0
131+
lcd ~/Projects/Work/GasWork/RelatedWork/web-view
132+
wincmd w
133+
argglobal
134+
if bufexists(fnamemodify("~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Types.hs", ":p")) | buffer ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Types.hs | else | edit ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Types.hs | endif
135+
if &buftype ==# 'terminal'
136+
silent file ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Types.hs
137+
endif
138+
balt ~/Projects/Work/GasWork/RelatedWork/web-view/src/Web/View/Style.hs
139+
setlocal fdm=manual
140+
setlocal fde=0
141+
setlocal fmr={{{,}}}
142+
setlocal fdi=#
143+
setlocal fdl=0
144+
setlocal fml=1
145+
setlocal fdn=20
146+
setlocal nofen
147+
silent! normal! zE
148+
31,63fold
149+
87,112fold
150+
150,168fold
151+
276,279fold
152+
392,413fold
153+
442,470fold
154+
510,519fold
155+
let &fdl = &fdl
156+
let s:l = 268 - ((19 * winheight(0) + 19) / 38)
157+
if s:l < 1 | let s:l = 1 | endif
158+
keepjumps exe s:l
159+
normal! zt
160+
keepjumps 268
161+
normal! 0
162+
lcd ~/Projects/Work/GasWork/RelatedWork/web-view
163+
wincmd w
164+
exe '1resize ' . ((&lines * 38 + 39) / 79)
165+
exe 'vert 1resize ' . ((&columns * 91 + 91) / 182)
166+
exe '2resize ' . ((&lines * 38 + 39) / 79)
167+
exe 'vert 2resize ' . ((&columns * 91 + 91) / 182)
168+
exe '3resize ' . ((&lines * 38 + 39) / 79)
169+
exe 'vert 3resize ' . ((&columns * 90 + 91) / 182)
170+
exe '4resize ' . ((&lines * 38 + 39) / 79)
171+
exe 'vert 4resize ' . ((&columns * 90 + 91) / 182)
172+
tabnext 1
173+
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
174+
silent exe 'bwipe ' . s:wipebuf
175+
endif
176+
unlet! s:wipebuf
177+
set winheight=1 winwidth=20
178+
let &shortmess = s:shortmess_save
179+
let &winminheight = s:save_winminheight
180+
let &winminwidth = s:save_winminwidth
181+
let s:sx = expand("<sfile>:p:r")."x.vim"
182+
if filereadable(s:sx)
183+
exe "source " . fnameescape(s:sx)
184+
endif
185+
let &g:so = s:so_save | let &g:siso = s:siso_save
186+
set hlsearch
187+
let g:this_session = v:this_session
188+
let g:this_obsession = v:this_session
189+
doautoall SessionLoadPost
190+
unlet SessionLoad
191+
" vim: set ft=vim :

bin/dev

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ watchexec -e hs,yaml cabal test &
2222

2323
# Autoreload on save. Show errors and warnings
2424
# run even if warnings
25-
cd example
26-
ghcid --command "cabal repl example" -T Main.main -W
25+
ghcid --command="cabal repl exe:example lib:web-view" --run=Main.main --warnings --reload=./embed/preflight.css

cabal.project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
tests: True
2+
multi-repl: True
23
packages:
34
.
5+
example

example/cabal.project

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)