Skip to content

Commit 28e3c82

Browse files
Merge #837 Readme: add profiling info, overall update
2 parents 5c50295 + 4555c07 commit 28e3c82

File tree

1 file changed

+70
-49
lines changed

1 file changed

+70
-49
lines changed

ReadMe.md

Lines changed: 70 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,26 @@ Parser, evaluator and type checker for the Nix language written in Haskell.
4949
## Prerequisites
5050
Tooling is WIP, `nix-shell` and `nix-store` are still used for their purpose, so, to access them Nix is required to be installed.
5151

52-
*Disclaimer*: Current `derivationStrict` primOp implementation and so every evaluation of a derivation into a store path currently relies on the `hnix-store-remote`, which for those operations relies on the running `nix-daemon`, and so operations use/produce effects into the `/nix/store`. Be cautious - it is effectful.
52+
*Disclaimer*: Since still using Nix for some operations, current `derivationStrict` primOp implementation and so evaluations of a derivation into a store path currently rely on the `hnix-store-remote`, which for those operations relies on the running `nix-daemon`, and so operations use/produce effects into the `/nix/store`. Be cautious - it is effectful (produces `/nix/store` entries).
5353

5454
## Getting Started
5555

56+
### Git clone
57+
5658
```shell
57-
# Note: --recursive
58-
git clone --recursive 'https://github.com/haskell-nix/hnix.git'
59-
cd hnix
59+
git clone --recursive 'https://github.com/haskell-nix/hnix.git' && cd hnix
6060
```
6161

6262

63-
### Cachix prebuild binary caches
63+
### (optional) Cachix prebuild binary caches
64+
65+
If you would use our Nix-shell environment for development, you can connect to our Cachix HNix build caches:
6466

65-
If you opt in to use of Nix environment, please enable the official HNix Cachix binary cache:
67+
1. Run:
68+
```shell
69+
nix-env -iA cachix -f https://cachix.org/api/v1/install
70+
```
6671

67-
1. Go through https://cachix.org/ and set it up.
6872

6973
2. Run: `cachix use hnix`
7074

@@ -74,37 +78,37 @@ If you opt in to use of Nix environment, please enable the official HNix Cachix
7478
Cabal [Quickstart](https://cabal.readthedocs.io/en/3.4/nix-local-build.html).
7579

7680
1. (Optional), to enter the projects reproducible Nix environment:
77-
```shell
78-
nix-shell
79-
```
80-
81+
```shell
82+
nix-shell
83+
```
84+
8185
2. Building:
82-
```shell
83-
cabal v2-configure
84-
cabal v2-build
85-
```
86-
86+
```shell
87+
cabal v2-configure
88+
cabal v2-build
89+
```
90+
8791
3. Loading the project into `ghci` REPL:
88-
```shell
89-
cabal v2-repl
90-
```
91-
92+
```shell
93+
cabal v2-repl
94+
```
95+
9296
4. Testing:
9397

94-
* Default suite:
95-
```shell
96-
cabal v2-test
97-
```
98-
99-
* All available tests:
100-
```shell
101-
env ALL_TESTS=yes cabal v2-test
102-
```
103-
104-
* Selected (list of tests is in `tests/Main.hs`):
105-
```shell
106-
env NIXPKGS_TESTS=yes PRETTY_TESTS=1 cabal v2-test
107-
```
98+
* Default suite:
99+
```shell
100+
cabal v2-test
101+
```
102+
103+
* All available tests:
104+
```shell
105+
env ALL_TESTS=yes cabal v2-test
106+
```
107+
108+
* Selected (list of tests is in `tests/Main.hs`):
109+
```shell
110+
env NIXPKGS_TESTS=yes PRETTY_TESTS=1 cabal v2-test
111+
```
108112

109113
#### Checking the project
110114

@@ -123,10 +127,23 @@ GHC User Manual has a full ["Profiling"](https://ghc.gitlab.haskell.org/ghc/doc/
123127
To build `hnix` with profiling enabled:
124128

125129
```shell
126-
cabal v2-configure --enable-tests --enable-profiling --flags=profiling
127-
cabal v2-run hnix -- <args> +RTS -p
130+
cabal v2-run hnix --enable-profiling --flags=profiling -- <args> +RTS -p
131+
```
132+
133+
Or to put simply:
134+
```shell
135+
# Run profiling for evaluation of a Firefox package.
136+
# Generate:
137+
# * for all functions
138+
# * time profiling data
139+
# * memory allocation profiling data
140+
# * in the JSON profiling format
141+
cabal v2-run --enable-profiling --flags=profiling --enable-library-profiling --profiling-detail='all-functions' hnix -- --eval --expr '(import <nixpkgs> {}).firefox.outPath' +RTS -Pj
142+
143+
# Then, upload the `hnix.prof` to the https://www.speedscope.app/ to analyze it.
128144
```
129-
where "RTS" stands for "RunTime System" and has a lot of options, GHC User Manual has ["Running a compiled program"/"Setting RTS options"](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/runtime_control.html) sections describing them.
145+
146+
"RTS" stands for "RunTime System" and has a lot of options, GHC User Manual has ["Running a compiled program"/"Setting RTS options"](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/runtime_control.html) sections describing them.
130147

131148
##### Full debug info
132149

@@ -267,7 +284,7 @@ hnix --reduce bug.nix --eval --expr 'import <nixpkgs> {}'
267284

268285
### REPL
269286

270-
Ot enter REPL:
287+
To enter REPL:
271288
```shell
272289
hnix --repl
273290
```
@@ -306,26 +323,30 @@ hnix \
306323

307324
## Contributing
308325

309-
There is a Wiki article: [Design of the HNix code base](https://github.com/haskell-nix/hnix/wiki/Design-of-the-HNix-code-base).
326+
* The Haskell Language Server (HLS) works great with our project.
310327

311-
Haskell Language Server & Cabal development. Or development in the Nix shell environment.
328+
* [Design of the HNix code base Wiki article](https://github.com/haskell-nix/hnix/wiki/Design-of-the-HNix-code-base).
312329

313330
1. If something in the [quests](https://github.com/haskell-nix/hnix/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22+no%3Aassignee) looks interesting, look through the thread and leave a comment taking it, to let others know you're working on it.
314331

315332
2. You are free to chat with everyone on [Gitter](https://gitter.im/haskell-nix/Lobby).
316333

317334
3. When the pull request is ready to be submitted, to save time - please, test it with:
318-
319-
```shell
320-
git submodule update --init --recursive
321-
cabal v2-test
322-
```
323-
324-
Please, check that all default tests that were passing prior are still passing for the PR, it is faster to check that locally than through CI. It's OK if no new tests are passing.
325-
326-
335+
336+
```shell
337+
cabal v2-test
338+
339+
# If forgot to clone recursively, run:
340+
# git submodule update --init --recursive
341+
```
342+
343+
Please, check that all default tests that were passing prior are still passing. It's OK if no new tests are passing.
344+
345+
327346
### (optional) Minimalistic development status loop with amazing [`ghcid`](https://github.com/ndmitchell/ghcid)
328347
348+
If HLS is not your cup of yea:
349+
329350
```shell
330351
ghcid --command="cabal v2-repl --repl-options=-fno-code --repl-options=-fno-break-on-exception --repl-options=-fno-break-on-error --repl-options=-v1 --repl-options=-ferror-spans --repl-options=-j"
331352
```

0 commit comments

Comments
 (0)