You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rewriting the `flake.nix` to avoid `stacklock2nix` and use
`some-cabal-hashes` for faster builds.
* also removed non-standard dependencies `tasty-test-reporter` and
`profiteur`
* the `cabal.project.freeze` file is updated to be consistent with the
`nix` build
* dependency differences to `stack` LTS-22.23 were checked and are
harmless (patch-level only, and all but 3 in test dependencies anyway)
---------
Co-authored-by: Julian Kuners <[email protected]>
Copy file name to clipboardexpand all lines: README.md
+17-15
Original file line number
Diff line number
Diff line change
@@ -139,22 +139,24 @@ Make sure that the file wasn't overwritten, if it was add the `experimental-feat
139
139
### Formatting
140
140
The CI requires all Haskell files to be formatted via [fourmolu](https://hackage.haskell.org/package/fourmolu).
141
141
142
-
If using VSCode, please refer to the language server section above. If not, the easiest way to do this locally is to run
142
+
If using VSCode, please refer to the language server section above. If not, the easiest way to do this locally is by using the `nix` development shell `#style`, which provides `fourmolu` in the version used by CI for checking the format.
143
143
144
144
```
145
-
nix run .#format
145
+
nix develop .#style --command scripts/fourmolu.sh
146
146
```
147
147
148
-
This will format all the haskell files in the given folder and all sub-folders. You can `cd` into a particular subfolder and run the command there, or if you only want to format a specific file, you can provide it as an argument to the above command:
149
-
148
+
This script will run `fourmolu` to format all Haskell files in the project. You can also leave out the `--command ...` part and use `fourmolu` in the interactive `nix develop` shell to format particular files or subfolders:
150
149
```
151
-
nix run .#format Foo.hs
150
+
$ nix develop .#style
151
+
<nix-develop>$ fourmolu path/to/Foo.hs
152
+
... outputs the formatted file
153
+
<nix-develop>$ cd a/sub/directory && fourmolu
152
154
```
153
155
154
-
### Nix dev shell
156
+
### Nix dev shell for building
155
157
156
-
We provide a development nix shell with a suitable development environment and
157
-
a binary cache at [runtimeverification.cachix.org]. The development can be launched via `nix develop` and then calling `stack build/test/etc`.
158
+
We provide a development nix shell with a suitable development environment and a binary cache at [runtimeverification.cachix.org].
159
+
The development can be launched via `nix develop .#cabal` and then calling `cabal build/test/etc`.
158
160
159
161
### Nix-direnv
160
162
@@ -166,17 +168,17 @@ echo "use flake" > .envrc
166
168
167
169
Finally, run `direnv allow` inside the repo folder to load up the nix shell.
168
170
169
-
Note that only `cabal` currently works within the nix shell and since it does not support the HPack `package.yaml` file format, any changes to this file will require running `hpack` before they are picked up by cabal.
171
+
Note that only `cabal` currently works within the nix shell and since it does not support the HPack `package.yaml` file format, any changes to this file will require running `hpack` before they are picked up by cabal. The `*.cabal` files are checked in but not intended for manual editing if a `package.yaml` exists.
170
172
171
173
### Upgrading dependencies
172
174
173
-
We use `stack.yaml` (and hence `stack.yaml.lock`) as the source of truth about the Haskell package set the project is built with. The Nix flake uses [stacklock2nix](https://github.com/cdepillabout/stacklock2nix) to make the packages specified by the lock file available to `cabal-install` inside Nix.
174
-
175
-
Any GHC or resolver upgrades must double-check the `ghcVersion` value in the [`flake.nix`](https://github.com/runtimeverification/haskell-backend/blob/master/flake.nix#L32) file.
176
-
177
-
It may also be required to update [`all-cabal-hashes`](https://github.com/runtimeverification/haskell-backend/blob/master/flake.nix#L101).
175
+
We aim to use `stack.yaml` and its chosen LTS resolver as the source of truth for the Haskell package set the projectis built with.
176
+
However, the nix flake uses `cabal2nix` to build cabal projects, using Haskell packages from `nixpkgs` and overriden with packages from Hackage with source overrides. `nixpkgs` provides some packages in slightly different versions, but the discrepancies are minor and mainly in test dependencies.
177
+
A `cabal.project.freeze` file has been added to ensure the consistent use of known dependency versions when building outside `nix`.
178
+
To optimize the build time of overriden packages, [some-cabal-hashes](https://github.com/lf-/nix-lib/blob/main/lib/some-cabal-hashes.nix) is utilized when overriding sources.
178
179
179
-
To support the scenario of building the project with `cabal-install` outside of Nix, We use a `cabal.project.freeze` file to pin the dependencies to what the current `stack` resolver is using. The script [`scripts/freeze-cabal-to-stack-resolver.sh`](https://github.com/runtimeverification/haskell-backend/tree/master/scripts/freeze-cabal-to-stack-resolver.sh) should do most of that work, and [`scripts/check-cabal-stack-sync.sh`](https://github.com/runtimeverification/haskell-backend/tree/master/scripts/check-cabal-stack-sync.sh) checks the result. Some manual adjustments will still be necessary for the `nix` builds in CI and locally to work.
180
+
An upgrade to the stack resolver will therefore require a complete revision of the dependencies, starting with the GHC version (specified in the `nix` flake under `ghcVer`, and revising the overrides in `flake.nix`.
181
+
As a starting point to this process, the script [`scripts/freeze-cabal-to-stack-resolver.sh`](https://github.com/runtimeverification/haskell-backend/tree/master/scripts/freeze-cabal-to-stack-resolver.sh) can be used to generate a new `cabal.project.freeze` file which pins the dependencies to what the current `stack` resolver is using. Some manual adjustments will usually be necessary for the `nix` builds in CI and locally to work.
0 commit comments