Skip to content

Commit 677266d

Browse files
authored
Merge pull request #5232 from sellout/doc-nix-cache
2 parents ef62cd9 + 734b6c4 commit 677266d

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

development.markdown

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ We use 0.5.0.1 of Ormolu and CI will add an extra commit, if needed, to autoform
2222

2323
Also note that you can always wrap a comment around some code you don't want Ormolu to touch, using:
2424

25-
```
25+
```haskell
2626
{- ORMOLU_DISABLE -}
2727
dontFormatMe = do blah
2828
blah
@@ -96,11 +96,13 @@ This codebase uses symlinks as a workaround for some inconveniences in the `here
9696

9797
First you'll need to enable "Developer Mode" in your Windows settings.
9898

99-
See https://consumer.huawei.com/en/support/content/en-us15594140/
99+
> See https://consumer.huawei.com/en/support/content/en-us15594140/
100100
101101
Then you'll need to enable symlink support in your `git` configuration, e.g.
102102

103-
`git config core.symlinks true`
103+
```shell
104+
git config core.symlinks true
105+
```
104106

105107
And then ask `git` to fix up your symlinks with `git checkout .`
106108

@@ -113,10 +115,41 @@ Stack doesn't work deterministically in Windows due to mismatched expectations a
113115

114116
## Building with Nix
115117

118+
__NB__: It is important that the Unison Nix cache is trusted when building, otherwise you will likely end up building hundreds of packages, including GHC itself.
119+
120+
The recommended way to do this is to add the public key and URL for the cache to your system’s Nix configuration. /etc/nix/nix.conf should have lines similar to
121+
```conf
122+
trusted-public-keys = unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k=
123+
trusted-substituters = https://unison.cachix.org
124+
```
125+
these lines could be prefixed with `extra-` and they may have additional entries besides the ones for our cache.
126+
127+
This command should work if you don’t want to edit the file manually:
128+
```shell
129+
sudo sh -c 'echo "extra-trusted-public-keys = unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k=
130+
extra-trusted-substituters = https://unison.cachix.org" >>/etc/nix/nix.conf'
131+
```
132+
After updating /etc/nix/nix.conf, you need to restart the Nix daemon. To do this on
133+
- Ubuntu: `sudo systemctl restart nix-daemon`
134+
- MacOS:
135+
```shell
136+
sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist
137+
sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
138+
```
139+
140+
If you use NixOS, you may instead add this via your configuration.nix with
141+
```nix
142+
nix.settings.trusted-public-keys = ["unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k="];
143+
nix.settings.trusted-substituters = ["https://unison.cachix.org"];
144+
```
145+
and run `sudo nixos-rebuild switch` afterward.
146+
147+
It is _not_ recommended to add your user to `trusted-users`. This _can_ make enabling flake configurations simpler (like the Unison Nix cache here), but [it is equivalent to giving that user root access (without need for sudo)](https://nix.dev/manual/nix/2.23/command-ref/conf-file.html#conf-trusted-users).
148+
116149
## Building package components with nix
117150

118151
### Build the unison executable
119-
```
152+
```shell
120153
nix build
121154
```
122155

@@ -125,7 +158,7 @@ This is specified with the normal
125158
`<package>:<component-type>:<component-name>` triple.
126159

127160
Some examples:
128-
```
161+
```shell
129162
nix build '.#component-unison-cli:lib:unison-cli'
130163
nix build '.#component-unison-syntax:test:syntax-tests'
131164
nix build '.#component-unison-cli:exe:transcripts'
@@ -143,7 +176,7 @@ include:
143176
- ormolu
144177
- haskell-language-server
145178

146-
```
179+
```shell
147180
nix develop
148181
```
149182

@@ -153,7 +186,7 @@ versions of the compiler and other development tools. Additionally,
153186
all non-local haskell dependencies (including profiling dependencies)
154187
are provided in the nix shell.
155188

156-
```
189+
```shell
157190
nix develop '.#cabal-local'
158191
```
159192

@@ -163,17 +196,17 @@ versions of the compiler and other development tools. Additionally,
163196
all haskell dependencies of this package are provided by the nix shell
164197
(including profiling dependencies).
165198

166-
```
199+
```shell
167200
nix develop '.#cabal-<package-name>'
168201
```
169202

170203
for example:
171204

172-
```
205+
```shell
173206
nix develop '.#cabal-unison-cli'
174207
```
175208
or
176-
```
209+
```shell
177210
nix develop '.#cabal-unison-parser-typechecker'
178211
```
179212

@@ -182,7 +215,7 @@ want to profile `unison-cli-main:exe:unison` then you could get into one of thes
182215
shells, cd into its directory, then run the program with
183216
profiling.
184217

185-
```
218+
```shell
186219
nix develop '.#cabal-unison-parser-typechecker'
187220
cd unison-cli
188221
cabal run --enable-profiling unison-cli-main:exe:unison -- +RTS -p

0 commit comments

Comments
 (0)