Skip to content

Commit 5903d28

Browse files
committed
Merge branch 'master' into 2063-back-button
2 parents fe000b4 + 2722e4e commit 5903d28

35 files changed

+515
-634
lines changed

.github/patch-flakes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
$file_contents = file_get_contents('./flake.nix');
33
$new_content_with_ref = preg_replace('/(ihp\.url = \")(.+)(\")/', '$1github:' . $argv[2] . '?rev=' . $argv[3] . '$3', $file_contents);
4-
$new_content_with_ref = str_replace("p.ihp", "p.ihp wreq mmark mmark-ext strip-ansi-escape stripe-signature stripe-concepts http-conduit aeson-casing tz tagsoup ihp-zip minio-hs hs-brotli wai-middleware-brotli fakedata jwt ihp-openai ihp-graphql unordered-containers minimorph", $new_content_with_ref);
4+
$new_content_with_ref = str_replace("p.ihp", "p.ihp wreq mmark mmark-ext strip-ansi-escape stripe-signature stripe-concepts http-conduit aeson-casing tz tagsoup ihp-zip minio-hs fakedata jwt ihp-openai ihp-graphql unordered-containers minimorph", $new_content_with_ref);
55
$new_content_with_ref = str_replace("# Native dependencies, e.g. imagemagick", "nodejs imagemagick", $new_content_with_ref);
66
file_put_contents('./flake.nix', $new_content_with_ref);
77
?>

.github/workflows/build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414
steps:
1515
- uses: actions/checkout@v4
16-
- uses: cachix/install-nix-action@v31
16+
- uses: wimpysworld/nothing-but-nix@main
1717
with:
18-
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/d899609c2a22bbd345d2ed200c6ebc08a772ccc9.tar.gz
18+
hatchet-protocol: 'rampage'
19+
if: matrix.os == 'ubuntu-latest'
20+
- uses: DeterminateSystems/nix-installer-action@main
21+
with:
22+
determinate: true
23+
extra-conf: "lazy-trees = true"
1924
if: matrix.os != 'ARM64'
2025
- uses: cachix/cachix-action@v16
2126
with:

.github/workflows/docs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: cachix/install-nix-action@v31
13+
- uses: DeterminateSystems/nix-installer-action@main
1414
with:
15-
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/d899609c2a22bbd345d2ed200c6ebc08a772ccc9.tar.gz
15+
determinate: true
16+
extra-conf: "lazy-trees = true"
1617
- uses: cachix/cachix-action@v16
1718
with:
1819
name: digitallyinduced

.github/workflows/ihp-new.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: cachix/install-nix-action@v31
13+
- uses: DeterminateSystems/nix-installer-action@main
1414
with:
15-
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/d899609c2a22bbd345d2ed200c6ebc08a772ccc9.tar.gz
15+
determinate: true
16+
extra-conf: "lazy-trees = true"
1617
- uses: cachix/cachix-action@v16
1718
with:
1819
name: digitallyinduced

.github/workflows/keep_releases_in_cachix.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414
steps:
1515
- uses: actions/checkout@v4
16-
- uses: cachix/install-nix-action@v31
16+
- uses: DeterminateSystems/nix-installer-action@main
1717
with:
18-
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/d899609c2a22bbd345d2ed200c6ebc08a772ccc9.tar.gz
18+
determinate: true
19+
extra-conf: "lazy-trees = true"
1920
if: matrix.os != 'ARM64'
2021
- uses: cachix/cachix-action@v16
2122
with:

CONTRIBUTING.md

Lines changed: 23 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -17,93 +17,58 @@ If you don't have a project, first make sure you have the latest version of `ihp
1717
# Set up a local IHP project
1818
ihp-new myproject
1919
cd myproject
20-
devenv up
2120
```
2221

23-
Running `devenv up` is necessary, even if you don't intend to run it this way (e.g. you intend to do development and don't intend to run it "normally"), to do some initial setup like creating the database. You can keep `devenv up` running, as it will pick up any changes to the custom app or the IHP, and save you the hassle of manually recompiling from ghci on every change.
24-
2522
Clone the IHP repository into the project directory. The `IHP` directory is added to the GHC search path in `applicationGhciConfig`. Therefore when the `IHP` directory exists, GHC will load all IHP modules from there.
2623

2724
```
2825
git clone git@github.com:digitallyinduced/ihp.git IHP
29-
# Enable direnv
3026
cd IHP
31-
direnv allow
32-
# Go back to the project root (do not run inside the IHP directory)
33-
cd -
34-
```
3527
36-
If the compiler can't locate certain IHP dependencies, it may be due to nix not updating IHP. In these instances, run the following command from the host project:
28+
# Patch flake.nix in the parent directory to use local IHP path
29+
sed -i "s|ihp.url = .*|ihp.url = \"path://$(pwd)\";|" ../flake.nix
3730
38-
```
39-
nix flake lock --update-input ihp
40-
```
31+
# Enable direnv
32+
direnv allow
4133
42-
### Faster Haskell Builds
34+
# Switch back to the host project directory
35+
cd -
36+
```
4337

44-
Uncomment the `configureFlags = [ "--flag FastBuild" ];` and `doHaddock = false;` lines in the `IHP/ihp.nix` for fast rebuilds, otherwise you could up waiting up to half an hour while IHP builds itself.
38+
You can now run `devenv up` in the host project directory to start the development server. However, if you'd like to change the DevServer you should stay on the
4539

46-
We need to make sure not to commit the changes of `IHP/ihp.nix`
47-
To help us with that, you can run this from the root of your project `cd IHP && git update-index --assume-unchanged ihp.nix`, so git will ignore your changes.
40+
### Running the development server
4841

49-
### Nix Changes
5042

51-
If you're testing local nix changes, you need to change your `flake.nix` to point to the IHP project instead of pulling it from github:
43+
When making changes to the development tooling, we have to start the server differently, without `devenv up`. We have run the following commands in the `IHP` directory:
5244

53-
```nix
54-
{
55-
inputs = {
56-
# The path needs to be absolute
57-
ihp.url = "path:///Users/myuser/someproject/IHP";
58-
# ...
59-
};
6045
```
46+
# Optional - you can set the `DEBUG` environment variable to enable debug logging
47+
export DEBUG=1
6148
62-
After that run `nix flake update`.
63-
64-
### Running the latest IHP `master`
65-
66-
When contributing to IHP core you will want to have your PRs synced with `master`. Your `flake.nix` should have this line:
6749
68-
```nix
69-
{
70-
ihp.url = "github:digitallyinduced/ihp";
71-
}
72-
```
73-
74-
Then every time you'd like to update to the latest master, you'll run:
50+
ghci
51+
:l ihp/ihp-ide/exe/IHP/IDE/DevServer.hs
7552
53+
# Start the server
54+
mainInParentDirectory
7655
```
77-
nix flake update
78-
direnv allow
79-
```
80-
81-
Note that it takes around 30 minutes for the IHP GitHub actions to prepare a binary build of IHP. If you run latest master and the GitHub actions aren't finished yet, you will notice that your computer needs to build IHP from scratch which takes a lot of time. You can wait for the GitHub action to complete or point to a specific IHP commit to avoid long build times.
82-
83-
### Running the development server
8456

57+
We don't need to start postgres as the IDE starts it automatically.
8558

86-
When making changes to the development tooling, we have to start the server differently, without `devenv up`. We have to
87-
use `make console` to load your application together with the framework located in `IHP`.
59+
If you ever switch back to using the upstream version, just restore the original line in flake.nix (e.g., ihp.url = "github:digitallyinduced/ihp";), and then run from the host directory:
8860

8961
```
90-
ghci
91-
:l ihp/ihp-ide/exe/IHP/IDE/DevServer.hs
92-
main
62+
nix flake lock --update-input ihp
9363
```
9464

95-
We don't need to start postgres as the IDE starts it automatically.
65+
### Faster Haskell Builds
9666

97-
#### Debugging the development server
67+
Uncomment the `configureFlags = [ "--flag FastBuild" ];` and `doHaddock = false;` lines in the `IHP/ihp.nix` for fast rebuilds, otherwise you could up waiting up to half an hour while IHP builds itself.
9868

99-
You can enable additional debug logging for the development server by setting the env variable `DEBUG=1`. Like this:
69+
We need to make sure not to commit the changes of `IHP/ihp.nix`
70+
To help us with that, you can run this from the root of your project `cd IHP && git update-index --assume-unchanged ihp.nix`, so git will ignore your changes.
10071

101-
```
102-
export DEBUG=1
103-
ghci
104-
:l ihp/ihp-ide/exe/IHP/IDE/DevServer.hs
105-
main
106-
```
10772

10873
## Working on the documentation
10974

Guide/editors.markdown

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ Install the following additional packages from [Melpa](https://melpa.org/#/getti
9797
- `haskell-mode` – enable basic Haskell support, syntax highlighting, ghci interaction
9898
- `envrc-mode` – lets eglot find the PATH to Haskell Language Server etc.
9999

100-
At the very least you need `(add-hook 'haskell-mode-hook #'eglot-ensure)`
101-
and `(envrc-global-mode +1)` in your `~/.emacs.d/init.el`, but you may also
102-
want to set up some keybindings to common language server functions
103-
(since by default none are included). Here's an example init file:
100+
At the very least you need `(envrc-global-mode +1)` in your
101+
`~/.emacs.d/init.el`, after that you should be able to `M-x eglot` to
102+
start the language server for a project. You may also want to set up
103+
some keybindings to common language server functions (since by default
104+
none are included). Here's an example init file:
104105

105106
```emacs-lisp
106107
(use-package envrc
@@ -109,6 +110,8 @@ want to set up some keybindings to common language server functions
109110
110111
(use-package eglot
111112
:config
113+
;; Optionally start the language server automatically (no need to
114+
;; run `M-x eglot` on startup) for every Haskell project you open:
112115
(add-hook 'haskell-mode-hook #'eglot-ensure)
113116
;; Optionally add keybindings to some common functions:
114117
:bind ((:map eglot-mode-map
@@ -130,6 +133,8 @@ want to set up some keybindings to common language server functions
130133
(server-start) ; for emacsclient / quick startup
131134
```
132135

136+
You should now be able to use the builtin go-to-definition bound to `M-.`.
137+
133138
(The built-in completion menu isn't very modern-looking, a good
134139
alternative if you want to add another plugin is
135140
[corfu](https://github.com/minad/corfu).)
@@ -149,8 +154,14 @@ and `chmod +x ~/bin/emacs-line`, then export this env var in your shell (e.g. in
149154
export IHP_EDITOR="$HOME/bin/emacs-line"
150155
```
151156

152-
Another useful package set that integrates with lsp/lsp-ui and loads the default nix environment from direnv as well as removing [common flycheck issue](https://github.com/joncol/dotfiles/blob/master/homedir/.emacs.d/init.el).
153-
This config also adds a jump to definition for functions bound to "C-c p":
157+
### lsp-mode instead of eglot
158+
159+
[lsp-mode](https://github.com/emacs-lsp/lsp-mode), with companion package [lsp-ui](https://emacs-lsp.github.io/lsp-ui/), is an alternative to the builtin eglot, with some different features.
160+
They are installable with `M-x package-install`.
161+
162+
Below is an example configuration for this package set, which also uses the [emacs-direnv](https://github.com/wbolster/emacs-direnv) package instead of [envrc](https://github.com/purcell/envrc) to load the nix environment.
163+
164+
This config also adds a peek-definition for functions using lsp-ui, bound to `C-c p`:
154165

155166
```emacs
156167
(use-package direnv
@@ -159,14 +170,17 @@ This config also adds a jump to definition for functions bound to "C-c p":
159170
(direnv-always-show-summary nil)
160171
:config
161172
(direnv-mode))
173+
162174
(use-package lsp-mode
163175
:custom
164176
(lsp-lens-enable nil)
165177
(lsp-enable-symbol-highlighting nil)
166-
167178
:hook
168179
(lsp-mode . lsp-enable-which-key-integration)
169-
180+
:init
181+
;; Optionally start the language server automatically (no need to
182+
;; run `M-x lsp` on startup) for every Haskell project you open:
183+
;; (add-hook 'haskell-mode-hook #'lsp)
170184
:config
171185
;; This is to make `lsp-mode' work with `direnv' and pick up the correct
172186
;; version of GHC.
@@ -179,39 +193,32 @@ This config also adds a jump to definition for functions bound to "C-c p":
179193
:config
180194
(setq lsp-ui-doc-position 'bottom))
181195
182-
;; (add-hook 'haskell-mode-hook #'lsp)
183-
(use-package flycheck-haskell
184-
;; Disabling this package, since it only gives error:
185-
;; "Reading Haskell configuration failed with exit code Segmentation fault and
186-
;; output:", when trying to run it in Nix/direnv setup.
187-
:disabled
188-
:hook (haskell-mode . flycheck-haskell-setup))
189-
190-
(add-hook 'haskell-mode-hook
191-
(lambda ()
192-
(rainbow-mode -1)
193-
;; we aren't evil:
194-
;; (evil-leader/set-key "x h" 'haskell-hoogle)
195-
;; (setq evil-shift-width 2)
196-
(define-key haskell-mode-map (kbd "C-c C-c C-s")
197-
'haskell-mode-stylish-buffer)
198-
(bind-key (kbd "C-c C-c C-a") 'haskell-sort-imports)
199-
(setq haskell-auto-insert-module-format-string
200-
"module %s\n () where\n\n")
201-
(haskell-auto-insert-module-template)
202-
(smartparens-mode)
203-
(sp-local-pair 'haskell-mode "{" "}")
204-
(setq haskell-hoogle-command nil)
205-
(ligature-mode)))
206-
207196
(use-package lsp-haskell
208197
:hook ((haskell-mode . lsp-deferred)
209198
(haskell-literate-mode . lsp-deferred))
210199
:custom
211200
(lsp-haskell-server-path "haskell-language-server"))
212201
213202
(use-package haskell-mode
214-
:defer)
203+
:defer
204+
:config
205+
(add-hook 'haskell-mode-hook
206+
(lambda ()
207+
;; Evil users may want these:
208+
;; (evil-leader/set-key "x h" 'haskell-hoogle)
209+
;; (setq evil-shift-width 2)
210+
(define-key haskell-mode-map (kbd "C-c C-c C-s")
211+
'haskell-mode-stylish-buffer)
212+
(bind-key (kbd "C-c C-c C-a") 'haskell-sort-imports)
213+
(setq haskell-auto-insert-module-format-string
214+
"module %s\n () where\n\n")
215+
(haskell-auto-insert-module-template)
216+
(when (require 'smartparens nil 'noerror)
217+
(smartparens-mode)
218+
(sp-local-pair 'haskell-mode "{" "}"))
219+
(setq haskell-hoogle-command nil)
220+
(when (require 'ligature nil 'noerror)
221+
(ligature-mode)))))
215222
```
216223

217224
## Using IHP with Vim / NeoVim

0 commit comments

Comments
 (0)