Skip to content

Commit 8608f3d

Browse files
authored
docs: getting started nix install or config revised (supabase#1853)
1 parent 0155d56 commit 8608f3d

File tree

1 file changed

+94
-22
lines changed

1 file changed

+94
-22
lines changed

nix/docs/start-here.md

Lines changed: 94 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,109 @@
1-
Let's go ahead and install Nix. To do that, we'll use the
2-
**[nix-installer tool]** by Determinate Systems. This works on many platforms,
3-
but most importantly it works on **aarch64 Linux** and **x86_64 Linux**. Use the
4-
following command in your shell, **it should work on any Linux distro of your
5-
choice**:
1+
## Uninstall Previous Nix Installation (if applicable)
62

7-
[nix-installer tool]: https://github.com/DeterminateSystems/nix-installer
3+
If you previously installed Nix using the Determinate Systems installer, you'll need to uninstall it first:
84

95
```bash
10-
curl \
11-
--proto '=https' --tlsv1.2 \
12-
-sSf -L https://install.determinate.systems/nix \
13-
| sh -s -- install
6+
sudo /nix/nix-installer uninstall
147
```
158

9+
If you installed Nix using a different method, follow the appropriate uninstall procedure for that installation method before proceeding.
10+
11+
## Update Existing Official Nix Installation
12+
13+
If you already have the official Nix installer (not Determinate Systems) installed, you can simply update your configuration instead of reinstalling:
14+
15+
### Step 1: Edit /etc/nix/nix.conf
16+
17+
Add or update the following configuration in `/etc/nix/nix.conf`:
18+
19+
```
20+
allowed-users = *
21+
always-allow-substitutes = true
22+
auto-optimise-store = false
23+
build-users-group = nixbld
24+
builders-use-substitutes = true
25+
cores = 0
26+
experimental-features = nix-command flakes
27+
max-jobs = auto
28+
netrc-file =
29+
require-sigs = true
30+
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com https://postgrest.cachix.org https://cache.nixos.org/
31+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= postgrest.cachix.org-1:icgW4R15fz1+LqvhPjt4EnX/r19AaqxiVV+1olwlZtI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
32+
trusted-substituters =
33+
trusted-users = YOUR_USERNAME root
34+
extra-sandbox-paths =
35+
extra-substituters =
36+
```
37+
38+
**Important**: Replace `YOUR_USERNAME` with your actual username in the `trusted-users` line.
39+
40+
### Step 2: Restart the Nix Daemon
41+
42+
After updating the configuration, restart the Nix daemon:
43+
44+
**On macOS:**
45+
```bash
46+
sudo launchctl stop org.nixos.nix-daemon
47+
sudo launchctl start org.nixos.nix-daemon
48+
```
49+
50+
**On Linux (systemd):**
51+
```bash
52+
sudo systemctl restart nix-daemon
53+
```
54+
55+
Your Nix installation is now configured with the proper build caches and should work without substituter errors.
56+
57+
## Install Nix (Fresh Installation)
58+
59+
We'll use the official Nix installer with a custom configuration that includes our build caches and settings. This works on many platforms, including **aarch64 Linux**, **x86_64 Linux**, and **macOS**.
60+
61+
### Step 1: Create nix.conf
62+
63+
First, create a file named `nix.conf` with the following content:
64+
65+
```
66+
allowed-users = *
67+
always-allow-substitutes = true
68+
auto-optimise-store = false
69+
build-users-group = nixbld
70+
builders-use-substitutes = true
71+
cores = 0
72+
experimental-features = nix-command flakes
73+
max-jobs = auto
74+
netrc-file =
75+
require-sigs = true
76+
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com https://postgrest.cachix.org https://cache.nixos.org/
77+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= postgrest.cachix.org-1:icgW4R15fz1+LqvhPjt4EnX/r19AaqxiVV+1olwlZtI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
78+
trusted-substituters =
79+
trusted-users = YOUR_USERNAME root
80+
extra-sandbox-paths =
81+
extra-substituters =
82+
```
83+
84+
**Important**: Replace `YOUR_USERNAME` with your actual username in the `trusted-users` line.
85+
86+
### Step 2: Install Nix 2.29.2
87+
88+
Run the following command to install Nix 2.29.2 (the version used in CI) with the custom configuration:
89+
90+
```bash
91+
curl -L https://releases.nixos.org/nix/nix-2.29.2/install | sh -s -- --daemon --yes --nix-extra-conf-file ./nix.conf
92+
```
93+
94+
This will install Nix with our build caches pre-configured, which should eliminate substituter-related errors.
95+
1696
After you do this, **you must log in and log back out of your desktop
17-
environment** to get a new login session. This is so that your shell can have
18-
the Nix tools installed on `$PATH` and so that your user shell can see some
97+
environment** (or restart your terminal session) to get a new login session. This is so that your shell can have
98+
the Nix tools installed on `$PATH` and so that your user shell can see the
1999
extra settings.
20100

21101
You should now be able to do something like the following; try running these
22102
same commands on your machine:
23103

24104
```
25105
$ nix --version
26-
nix (Nix) 2.16.1
106+
nix (Nix) 2.29.2
27107
```
28108

29109
```
@@ -32,21 +112,13 @@ $ nix run nixpkgs#nix-info -- -m
32112
- host os: `Linux 5.15.90.1-microsoft-standard-WSL2, Ubuntu, 22.04.2 LTS (Jammy Jellyfish), nobuild`
33113
- multi-user?: `yes`
34114
- sandbox: `yes`
35-
- version: `nix-env (Nix) 2.16.1`
115+
- version: `nix-env (Nix) 2.29.2`
36116
- channels(root): `"nixpkgs"`
37117
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
38118
```
39119

40120
If the above worked, you're now cooking with gas!
41121

42-
> _**NOTE**_: While there is an upstream tool to install Nix, written in Bash,
43-
> we use the Determinate Systems installer — which will hopefully replace the
44-
> original — because it's faster, and takes care of several extra edge cases
45-
> that the original one couldn't handle, and makes several changes to the
46-
> default installed configuration to make things more user friendly. Determinate
47-
> Systems is staffed by many long-time Nix contributors and the creator of Nix,
48-
> and is trustworthy.
49-
50122
## Do some fun stuff
51123

52124
One of the best things about Nix that requires _very little_ knowledge of it is

0 commit comments

Comments
 (0)