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
Copy file name to clipboardExpand all lines: README-nix.md
+21-16Lines changed: 21 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,9 +88,11 @@ with all the dependencies required executing `nix develop o1js#default`.
88
88
nix develop o1js#default
89
89
```
90
90
91
-
The first time you run this command, you can expect it to take hours (or even a full day) to complete. Then, you will observe that the current devshell becomes a Nix shell with the right
91
+
On macos the first time you run this command, you can expect it to take hours (or even a full day) to complete, due to the lack of cached builds.
92
+
Then, you will observe that the current devshell becomes a Nix shell with the right
92
93
configuration for `o1js` and `mina`.
93
94
95
+
94
96
From within the shell, you can build o1js and update the bindings.
95
97
96
98
```console
@@ -114,28 +116,31 @@ nix develop mina
114
116
115
117
Using Nix can take up a lot of disk space if not optimized. Every time you run `nix develop {SOMETHING}`, Nix will create new generations taking gigabytes of data instead of replacing the old ones. This can soon become a problem in your hard disk if you don't handle it carefully. Here are a few indications that can help with this.
116
118
117
-
Nix has a garbage collector that **is not used by default** after every run. Instead, artifacts get accumulated in your disk unless configured otherwise. But if the full gargabe collector is executed (`nix-store --gc`), it will get the dependencies removed completely, and you can expect that the next time executing the Nix build will take hours to complete.
118
-
119
-
Instead, you can try to run `nix-env --delete-generations old` or any other time bound like `7d`. This will not have any effect on MacOS though. Alternatively, the [direnv](https://github.com/direnv/direnv) / [nix-direnv](https://github.com/nix-community/nix-direnv) tool can create garbage collector roots that won't be collected for removal. It just keeps one gc-root to the latest build of the dev shell so that `nix-store --gc` only removes older generations.
119
+
Nix has a garbage collector that **is not used by default** after every run. Instead, artifacts get accumulated in your disk unless configured otherwise.
120
+
This is why we recomend `auto-optimise-store = true` (you will be prompted to accept this). You can also run `nix-store --optimize` retroactively.
120
121
121
-
On top of that, adding `auto-optimise-store = true` to `/etc/nix/nix.conf` and running `nix-store --optimize` should help with disk usage, as it replaces duplicated files with symlinks.
122
+
If you still need to free up space you can run `nix-store --gc`, unfortunately this can slow down futurue nix builds by forcing you to rebuild dependencies.
123
+
This can be mitigated with [direnv](https://github.com/direnv/direnv) and [nix-direnv](https://github.com/nix-community/nix-direnv) which can create garbage collector roots,
124
+
keeping one gc-root to the latest build of the dev shell so that `nix-store --gc` won't remove it.
125
+
You can also create a gc root any time you run `nix build` (until you remove `./result`) so running `nix build o1js#bindings` before `nix-store --gc` may also help.
122
126
123
127
### Runtime optimization
124
128
125
-
Other configurations are worth adding into your `/etc/nix/nix.conf`:
You will be prompted to accept or reject these the first time you use nix in this repo.
131
+
You can also use `--accept-flake-config` to accept all of them.
133
132
134
-
The first of those flags tells the garbage collector to keep build time dependencies of current gc-roots, which should help reduce the amount of data that gets removed and rebuilt.
133
+
`max-jobs = auto`
134
+
For some reason the default is `1`.
135
135
136
-
The second flag increases the default number of jobs being 1, so that rebuilding from scratch will take shorter time.
136
+
`auto-optimize-store = true;`
137
+
When building slightly different versions of the same repo your nix store can fill up with coppies of the same files.
138
+
This saves space by replacing them with symlinks.
137
139
138
-
The last two lines tell Nix to use the Mina Foundation's cache whenever possible, which should as well speed things up when building code that has been build in Mina's CI before.
140
+
`substituters = ...`
141
+
`trusted-public-keys = ...`
142
+
These make sure you are using the mina-nix-cache which will save time by downloading any derivations already available.
143
+
Anything built in CI is added to this nix-cache, so it should make a big difference in build times.
0 commit comments