|
1 | 1 | # Installing a Binary Distribution |
2 | 2 |
|
3 | | -If you are using Linux or macOS versions up to 10.14 (Mojave), the |
4 | | -easiest way to install Nix is to run the following command: |
| 3 | +The easiest way to install Nix is to run the following command: |
5 | 4 |
|
6 | 5 | ```console |
7 | 6 | $ sh <(curl -L https://nixos.org/nix/install) |
8 | 7 | ``` |
9 | 8 |
|
10 | | -If you're using macOS 10.15 (Catalina) or newer, consult [the macOS |
11 | | -installation instructions](#macos-installation) before installing. |
| 9 | +This will run the installer interactively (causing it to explain what |
| 10 | +it is doing more explicitly, and perform the default "type" of install |
| 11 | +for your platform: |
| 12 | +- single-user on Linux |
| 13 | +- multi-user on macOS |
12 | 14 |
|
13 | | -As of Nix 2.1.0, the Nix installer will always default to creating a |
14 | | -single-user installation, however opting in to the multi-user |
15 | | -installation is highly recommended. |
| 15 | + > **Notes on read-only filesystem root in macOS 10.15 Catalina +** |
| 16 | + > |
| 17 | + > - It took some time to support this cleanly. You may see posts, |
| 18 | + > examples, and tutorials using obsolete workarounds. |
| 19 | + > - Supporting it cleanly made macOS installs too complex to qualify |
| 20 | + > as single-user, so this type is no longer supported on macOS. |
| 21 | +
|
| 22 | +We recommend the multi-user install if it supports your platform and |
| 23 | +you can authenticate with `sudo`. |
16 | 24 |
|
17 | 25 | # Single User Installation |
18 | 26 |
|
@@ -50,9 +58,9 @@ $ rm -rf /nix |
50 | 58 | The multi-user Nix installation creates system users, and a system |
51 | 59 | service for the Nix daemon. |
52 | 60 |
|
53 | | - - Linux running systemd, with SELinux disabled |
54 | | - |
55 | | - - macOS |
| 61 | +**Supported Systems** |
| 62 | +- Linux running systemd, with SELinux disabled |
| 63 | +- macOS |
56 | 64 |
|
57 | 65 | You can instruct the installer to perform a multi-user installation on |
58 | 66 | your system: |
@@ -96,165 +104,28 @@ sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist |
96 | 104 | There may also be references to Nix in `/etc/profile`, `/etc/bashrc`, |
97 | 105 | and `/etc/zshrc` which you may remove. |
98 | 106 |
|
99 | | -# macOS Installation |
100 | | - |
101 | | -Starting with macOS 10.15 (Catalina), the root filesystem is read-only. |
102 | | -This means `/nix` can no longer live on your system volume, and that |
103 | | -you'll need a workaround to install Nix. |
104 | | - |
105 | | -The recommended approach, which creates an unencrypted APFS volume for |
106 | | -your Nix store and a "synthetic" empty directory to mount it over at |
107 | | -`/nix`, is least likely to impair Nix or your system. |
108 | | - |
109 | | -> **Note** |
110 | | -> |
111 | | -> With all separate-volume approaches, it's possible something on your |
112 | | -> system (particularly daemons/services and restored apps) may need |
113 | | -> access to your Nix store before the volume is mounted. Adding |
114 | | -> additional encryption makes this more likely. |
115 | | -
|
116 | | -If you're using a recent Mac with a [T2 |
117 | | -chip](https://www.apple.com/euro/mac/shared/docs/Apple_T2_Security_Chip_Overview.pdf), |
118 | | -your drive will still be encrypted at rest (in which case "unencrypted" |
119 | | -is a bit of a misnomer). To use this approach, just install Nix with: |
120 | | - |
121 | | -```console |
122 | | -$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume |
123 | | -``` |
124 | | - |
125 | | -If you don't like the sound of this, you'll want to weigh the other |
126 | | -approaches and tradeoffs detailed in this section. |
127 | | - |
128 | | -> **Note** |
129 | | -> |
130 | | -> All of the known workarounds have drawbacks, but we hope better |
131 | | -> solutions will be available in the future. Some that we have our eye |
132 | | -> on are: |
133 | | -> |
134 | | -> 1. A true firmlink would enable the Nix store to live on the primary |
135 | | -> data volume without the build problems caused by the symlink |
136 | | -> approach. End users cannot currently create true firmlinks. |
137 | | -> |
138 | | -> 2. If the Nix store volume shared FileVault encryption with the |
139 | | -> primary data volume (probably by using the same volume group and |
140 | | -> role), FileVault encryption could be easily supported by the |
141 | | -> installer without requiring manual setup by each user. |
142 | | -
|
143 | | -## Change the Nix store path prefix |
144 | | - |
145 | | -Changing the default prefix for the Nix store is a simple approach which |
146 | | -enables you to leave it on your root volume, where it can take full |
147 | | -advantage of FileVault encryption if enabled. Unfortunately, this |
148 | | -approach also opts your device out of some benefits that are enabled by |
149 | | -using the same prefix across systems: |
150 | | - |
151 | | - - Your system won't be able to take advantage of the binary cache |
152 | | - (unless someone is able to stand up and support duplicate caching |
153 | | - infrastructure), which means you'll spend more time waiting for |
154 | | - builds. |
155 | | - |
156 | | - - It's harder to build and deploy packages to Linux systems. |
157 | | - |
158 | | -It would also possible (and often requested) to just apply this change |
159 | | -ecosystem-wide, but it's an intrusive process that has side effects we |
160 | | -want to avoid for now. |
161 | | - |
162 | | -## Use a separate encrypted volume |
163 | | - |
164 | | -If you like, you can also add encryption to the recommended approach |
165 | | -taken by the installer. You can do this by pre-creating an encrypted |
166 | | -volume before you run the installer--or you can run the installer and |
167 | | -encrypt the volume it creates later. |
168 | | - |
169 | | -In either case, adding encryption to a second volume isn't quite as |
170 | | -simple as enabling FileVault for your boot volume. Before you dive in, |
171 | | -there are a few things to weigh: |
172 | | - |
173 | | -1. The additional volume won't be encrypted with your existing |
174 | | - FileVault key, so you'll need another mechanism to decrypt the |
175 | | - volume. |
176 | | - |
177 | | -2. You can store the password in Keychain to automatically decrypt the |
178 | | - volume on boot--but it'll have to wait on Keychain and may not mount |
179 | | - before your GUI apps restore. If any of your launchd agents or apps |
180 | | - depend on Nix-installed software (for example, if you use a |
181 | | - Nix-installed login shell), the restore may fail or break. |
182 | | - |
183 | | - On a case-by-case basis, you may be able to work around this problem |
184 | | - by using `wait4path` to block execution until your executable is |
185 | | - available. |
186 | | - |
187 | | - It's also possible to decrypt and mount the volume earlier with a |
188 | | - login hook--but this mechanism appears to be deprecated and its |
189 | | - future is unclear. |
190 | | - |
191 | | -3. You can hard-code the password in the clear, so that your store |
192 | | - volume can be decrypted before Keychain is available. |
193 | | - |
194 | | -If you are comfortable navigating these tradeoffs, you can encrypt the |
195 | | -volume with something along the lines of: |
196 | | - |
197 | | -```console |
198 | | -$ diskutil apfs enableFileVault /nix -user disk |
199 | | -``` |
200 | | - |
201 | | -## Symlink the Nix store to a custom location |
202 | | - |
203 | | -Another simple approach is using `/etc/synthetic.conf` to symlink the |
204 | | -Nix store to the data volume. This option also enables your store to |
205 | | -share any configured FileVault encryption. Unfortunately, builds that |
206 | | -resolve the symlink may leak the canonical path or even fail. |
207 | | - |
208 | | -Because of these downsides, we can't recommend this approach. |
209 | | - |
210 | | -## Notes on the recommended approach |
211 | | - |
212 | | -This section goes into a little more detail on the recommended approach. |
213 | | -You don't need to understand it to run the installer, but it can serve |
214 | | -as a helpful reference if you run into trouble. |
215 | | - |
216 | | -1. In order to compose user-writable locations into the new read-only |
217 | | - system root, Apple introduced a new concept called `firmlinks`, |
218 | | - which it describes as a "bi-directional wormhole" between two |
219 | | - filesystems. You can see the current firmlinks in |
220 | | - `/usr/share/firmlinks`. Unfortunately, firmlinks aren't (currently?) |
221 | | - user-configurable. |
222 | | - |
223 | | - For special cases like NFS mount points or package manager roots, |
224 | | - [synthetic.conf(5)](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man5/synthetic.conf.5.html) |
225 | | - supports limited user-controlled file-creation (of symlinks, and |
226 | | - synthetic empty directories) at `/`. To create a synthetic empty |
227 | | - directory for mounting at `/nix`, add the following line to |
228 | | - `/etc/synthetic.conf` (create it if necessary): |
229 | | - |
230 | | - nix |
231 | | - |
232 | | -2. This configuration is applied at boot time, but you can use |
233 | | - `apfs.util` to trigger creation (not deletion) of new entries |
234 | | - without a reboot: |
235 | | - |
236 | | - ```console |
237 | | - $ /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B |
238 | | - ``` |
239 | | - |
240 | | -3. Create the new APFS volume with diskutil: |
241 | | - |
242 | | - ```console |
243 | | - $ sudo diskutil apfs addVolume diskX APFS 'Nix Store' -mountpoint /nix |
244 | | - ``` |
245 | | - |
246 | | -4. Using `vifs`, add the new mount to `/etc/fstab`. If it doesn't |
247 | | - already have other entries, it should look something like: |
248 | | - |
249 | | - # |
250 | | - # Warning - this file should only be modified with vifs(8) |
251 | | - # |
252 | | - # Failure to do so is unsupported and may be destructive. |
253 | | - # |
254 | | - LABEL=Nix\040Store /nix apfs rw,nobrowse |
255 | | - |
256 | | - The nobrowse setting will keep Spotlight from indexing this volume, |
257 | | - and keep it from showing up on your desktop. |
| 107 | +# macOS Installation <a name="sect-macos-installation-change-store-prefix"></a><a name="sect-macos-installation-encrypted-volume"></a><a name="sect-macos-installation-symlink"></a><a name="sect-macos-installation-recommended-notes"></a> |
| 108 | +<!-- Note: anchors above to catch permalinks to old explanations --> |
| 109 | + |
| 110 | +We believe we have ironed out how to cleanly support the read-only root |
| 111 | +on modern macOS. New installs will do this automatically, and you can |
| 112 | +also re-run a new installer to convert your existing setup. |
| 113 | + |
| 114 | +This section previously detailed the situation, options, and trade-offs, |
| 115 | +but it now only outlines what the installer does. You don't need to know |
| 116 | +this to run the installer, but it may help if you run into trouble: |
| 117 | + |
| 118 | +- create a new APFS volume for your Nix store |
| 119 | +- update `/etc/synthetic.conf` to direct macOS to create a "synthetic" |
| 120 | + empty root directory to mount your volume |
| 121 | +- specify mount options for the volume in `/etc/fstab` |
| 122 | +- if you have FileVault enabled |
| 123 | + - generate an encryption password |
| 124 | + - put it in your system Keychain |
| 125 | + - use it to encrypt the volume |
| 126 | +- create a system LaunchDaemon to mount this volume early enough in the |
| 127 | + boot process to avoid problems loading or restoring any programs that |
| 128 | + need access to your Nix store |
258 | 129 |
|
259 | 130 | # Installing a pinned Nix version from a URL |
260 | 131 |
|
|
0 commit comments