Skip to content

Commit af32f03

Browse files
committed
docs: move machine setup docs to respective directories
1 parent 94f2b33 commit af32f03

File tree

3 files changed

+188
-181
lines changed

3 files changed

+188
-181
lines changed

README.md

+8-181
Original file line numberDiff line numberDiff line change
@@ -5,187 +5,14 @@
55

66
## Setup
77

8-
### matebook
9-
10-
#### Partition layout
11-
12-
| Partition | Type | Size |
13-
|-----------|-------|---------|
14-
| p1 | boot | 512 MiB |
15-
| p2 | SWAP | 16 GiB |
16-
| p3 | btrfs | - |
17-
18-
#### Create encrypted partition and btrfs subvolumes
19-
20-
```bash
21-
export DISK=/dev/nvme0n1
22-
23-
cryptsetup --verify-passphrase -v luksFormat "$DISK"p3
24-
cryptsetup open "$DISK"p3 enc
25-
26-
mkfs.vfat -n boot "$DISK"p1
27-
mkswap "$DISK"p2
28-
swapon "$DISK"p2
29-
mkfs.btrfs /dev/mapper/enc
30-
31-
mount -t btrfs /dev/mapper/enc /mnt
32-
33-
btrfs subvolume create /mnt/home
34-
btrfs subvolume create /mnt/nix
35-
btrfs subvolume create /mnt/persist
36-
37-
umount /mnt
38-
```
39-
40-
#### Mount tmpfs, partitions and subvolumes and generate config
41-
42-
---
43-
**FIXME:** Mounting a ramdisk as root may be a bad idea for installation since
44-
building the config needs a lot of disk space. Consider mounting some temporary
45-
folder and deleting it afterwards or giving the tmpfs more ram.
46-
47-
---
48-
49-
```bash
50-
mount -t tmpfs none /mnt
51-
52-
mkdir -p /mnt/{boot,home,nix,persist}
53-
mount "$DISK"p1 /mnt/boot
54-
mount -o subvol=home,compress=zstd,noatime /dev/mapper/enc /mnt/home
55-
mount -o subvol=nix,compress=zstd,noatime /dev/mapper/enc /mnt/nix
56-
mount -o subvol=persist,compress=zstd,noatime /dev/mapper/enc /mnt/persist
57-
58-
nixos-generate-config --root /mnt
59-
```
60-
61-
Compare the generated hardware-configuration.nix with machines/matebook/hardware-configuration.nix,
62-
adjust and push to GitHub if needed.
63-
64-
#### Copy matebook ssh key to home directory
65-
66-
```bash
67-
mkdir -p /mnt/home/jakob/.ssh
68-
cp /path/to/.ssh/id_ed25519* /mnt/home/jakob/.ssh
69-
```
70-
71-
#### Install and reboot
72-
73-
```bash
74-
nixos-install --flake github:jakobkukla/nixos-config#matebook
75-
reboot
76-
```
77-
78-
#### Switch to root user and update nix channels to fix the command-not-found script
79-
80-
---
81-
**TODO:** Replace command-not-found.pl with nix-index and find
82-
a way to circumvent building the index manually.
83-
84-
---
85-
86-
```bash
87-
nix-channel --update
88-
```
89-
90-
### pc
91-
92-
#### Partition layout
93-
94-
| Partition | Type | Size |
95-
|-----------|-------|---------|
96-
| p1 | boot | 512 MiB |
97-
| p2 | zfs | - |
98-
99-
#### Create encrypted zfs pool, system container and datasets
100-
101-
Note the ashift value during zpool creation. From the Arch wiki:
102-
103-
Use -o ashift=9 for disks with a 512 byte physical sector size or -o ashift=12
104-
for disks with a 4096 byte physical sector size. See `lsblk -S -o NAME,PHY-SEC`
105-
to get the physical sector size of each SCSI/SATA disk. Remove -S if you want
106-
the same value from all devices.
107-
For NVMe drives, use `nvme id-ns /dev/nvmeXnY -H | grep "LBA Format"`
108-
to get which LBA format is in use.
109-
110-
```bash
111-
export DISK=/dev/nvme0n1
112-
113-
mkfs.vfat -n boot "$DISK"p1
114-
115-
# Create ZFS root pool
116-
zpool create \
117-
-o ashift=9 \
118-
-o autotrim=on \
119-
-R /mnt \
120-
-O acltype=posixacl \
121-
-O canmount=off \
122-
-O compression=on \
123-
-O dnodesize=auto \
124-
-O relatime=on \
125-
-O xattr=sa \
126-
-O mountpoint=none \
127-
rpool \
128-
"$DISK"p2
129-
130-
# Create encrypted ZFS root system container
131-
zfs create \
132-
-o canmount=off \
133-
-o mountpoint=none \
134-
-o encryption=on \
135-
-o keylocation=prompt \
136-
-o keyformat=passphrase \
137-
rpool/nixos
138-
139-
zfs create -o mountpoint=legacy rpool/nixos/root
140-
zfs snapshot rpool/nixos/root@blank
141-
142-
zfs create -o mountpoint=legacy rpool/nixos/home
143-
zfs create -o mountpoint=legacy rpool/nixos/nix
144-
zfs create -o mountpoint=legacy rpool/nixos/persist
145-
```
146-
147-
#### Mount tmpfs, partitions and datasets and generate config
148-
149-
```bash
150-
mount -t zfs rpool/nixos/root /mnt
151-
152-
mkdir -p /mnt/{boot,home,nix,persist}
153-
mount "$DISK"p1 /mnt/boot
154-
mount -t zfs rpool/nixos/home /mnt/home
155-
mount -t zfs rpool/nixos/nix /mnt/nix
156-
mount -t zfs rpool/nixos/persist /mnt/persist
157-
158-
nixos-generate-config --root /mnt
159-
```
160-
161-
Compare the generated hardware-configuration.nix with
162-
machines/pc/hardware-configuration.nix, adjust and push to GitHub if needed.
163-
164-
#### Copy pc ssh key to home directory
165-
166-
```bash
167-
mkdir -p /mnt/home/jakob/.ssh
168-
cp /path/to/.ssh/id_ed25519* /mnt/home/jakob/.ssh
169-
```
170-
171-
#### Install and reboot
172-
173-
```bash
174-
nixos-install --no-root-password --flake github:jakobkukla/nixos-config#pc
175-
reboot
176-
```
177-
178-
#### Switch to root user and update nix channels to fix the command-not-found script
179-
180-
---
181-
**TODO:** Replace command-not-found.pl with nix-index
182-
and find a way to circumvent building the index manually.
183-
184-
---
185-
186-
```bash
187-
nix-channel --update
188-
```
8+
Setup instructions for specific machines can be found in `machines/<machine>`.
9+
10+
| Machine | Setup Instructions |
11+
|-----------|------------------------------|
12+
| matebook | [README](machines/matebook) |
13+
| pc | [README](machines/pc) |
14+
| server | [README](machines/server) |
15+
| hifiberry | [README](machines/hifiberry) |
18916

19017
## Test in VM
19118

machines/matebook/README.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# matebook
2+
3+
## Partition layout
4+
5+
| Partition | Type | Size |
6+
|-----------|-------|---------|
7+
| p1 | boot | 512 MiB |
8+
| p2 | SWAP | 16 GiB |
9+
| p3 | btrfs | - |
10+
11+
## Create encrypted partition and btrfs subvolumes
12+
13+
```bash
14+
export DISK=/dev/nvme0n1
15+
16+
cryptsetup --verify-passphrase -v luksFormat "$DISK"p3
17+
cryptsetup open "$DISK"p3 enc
18+
19+
mkfs.vfat -n boot "$DISK"p1
20+
mkswap "$DISK"p2
21+
swapon "$DISK"p2
22+
mkfs.btrfs /dev/mapper/enc
23+
24+
mount -t btrfs /dev/mapper/enc /mnt
25+
26+
btrfs subvolume create /mnt/home
27+
btrfs subvolume create /mnt/nix
28+
btrfs subvolume create /mnt/persist
29+
30+
umount /mnt
31+
```
32+
33+
## Mount tmpfs, partitions and subvolumes and generate config
34+
35+
---
36+
**FIXME:** Mounting a ramdisk as root may be a bad idea for installation since
37+
building the config needs a lot of disk space. Consider mounting some temporary
38+
folder and deleting it afterwards or giving the tmpfs more ram.
39+
40+
---
41+
42+
```bash
43+
mount -t tmpfs none /mnt
44+
45+
mkdir -p /mnt/{boot,home,nix,persist}
46+
mount "$DISK"p1 /mnt/boot
47+
mount -o subvol=home,compress=zstd,noatime /dev/mapper/enc /mnt/home
48+
mount -o subvol=nix,compress=zstd,noatime /dev/mapper/enc /mnt/nix
49+
mount -o subvol=persist,compress=zstd,noatime /dev/mapper/enc /mnt/persist
50+
51+
nixos-generate-config --root /mnt
52+
```
53+
54+
Compare the generated hardware-configuration.nix with machines/matebook/hardware-configuration.nix,
55+
adjust and push to GitHub if needed.
56+
57+
## Copy matebook ssh key to home directory
58+
59+
```bash
60+
mkdir -p /mnt/home/jakob/.ssh
61+
cp /path/to/.ssh/id_ed25519* /mnt/home/jakob/.ssh
62+
```
63+
64+
## Install and reboot
65+
66+
```bash
67+
nixos-install --flake github:jakobkukla/nixos-config#matebook
68+
reboot
69+
```
70+
71+
## Switch to root user and update nix channels to fix the command-not-found script
72+
73+
---
74+
**TODO:** Replace command-not-found.pl with nix-index and find
75+
a way to circumvent building the index manually.
76+
77+
---
78+
79+
```bash
80+
nix-channel --update
81+
```

machines/pc/README.md

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# pc
2+
3+
## Partition layout
4+
5+
| Partition | Type | Size |
6+
|-----------|-------|---------|
7+
| p1 | boot | 512 MiB |
8+
| p2 | zfs | - |
9+
10+
## Create encrypted zfs pool, system container and datasets
11+
12+
Note the ashift value during zpool creation. From the Arch wiki:
13+
14+
Use -o ashift=9 for disks with a 512 byte physical sector size or -o ashift=12
15+
for disks with a 4096 byte physical sector size. See `lsblk -S -o NAME,PHY-SEC`
16+
to get the physical sector size of each SCSI/SATA disk. Remove -S if you want
17+
the same value from all devices.
18+
For NVMe drives, use `nvme id-ns /dev/nvmeXnY -H | grep "LBA Format"`
19+
to get which LBA format is in use.
20+
21+
```bash
22+
export DISK=/dev/nvme0n1
23+
24+
mkfs.vfat -n boot "$DISK"p1
25+
26+
# Create ZFS root pool
27+
zpool create \
28+
-o ashift=9 \
29+
-o autotrim=on \
30+
-R /mnt \
31+
-O acltype=posixacl \
32+
-O canmount=off \
33+
-O compression=on \
34+
-O dnodesize=auto \
35+
-O relatime=on \
36+
-O xattr=sa \
37+
-O mountpoint=none \
38+
rpool \
39+
"$DISK"p2
40+
41+
# Create encrypted ZFS root system container
42+
zfs create \
43+
-o canmount=off \
44+
-o mountpoint=none \
45+
-o encryption=on \
46+
-o keylocation=prompt \
47+
-o keyformat=passphrase \
48+
rpool/nixos
49+
50+
zfs create -o mountpoint=legacy rpool/nixos/root
51+
zfs snapshot rpool/nixos/root@blank
52+
53+
zfs create -o mountpoint=legacy rpool/nixos/home
54+
zfs create -o mountpoint=legacy rpool/nixos/nix
55+
zfs create -o mountpoint=legacy rpool/nixos/persist
56+
```
57+
58+
## Mount tmpfs, partitions and datasets and generate config
59+
60+
```bash
61+
mount -t zfs rpool/nixos/root /mnt
62+
63+
mkdir -p /mnt/{boot,home,nix,persist}
64+
mount "$DISK"p1 /mnt/boot
65+
mount -t zfs rpool/nixos/home /mnt/home
66+
mount -t zfs rpool/nixos/nix /mnt/nix
67+
mount -t zfs rpool/nixos/persist /mnt/persist
68+
69+
nixos-generate-config --root /mnt
70+
```
71+
72+
Compare the generated hardware-configuration.nix with
73+
machines/pc/hardware-configuration.nix, adjust and push to GitHub if needed.
74+
75+
## Copy pc ssh key to home directory
76+
77+
```bash
78+
mkdir -p /mnt/home/jakob/.ssh
79+
cp /path/to/.ssh/id_ed25519* /mnt/home/jakob/.ssh
80+
```
81+
82+
## Install and reboot
83+
84+
```bash
85+
nixos-install --no-root-password --flake github:jakobkukla/nixos-config#pc
86+
reboot
87+
```
88+
89+
## Switch to root user and update nix channels to fix the command-not-found script
90+
91+
---
92+
**TODO:** Replace command-not-found.pl with nix-index
93+
and find a way to circumvent building the index manually.
94+
95+
---
96+
97+
```bash
98+
nix-channel --update
99+
```

0 commit comments

Comments
 (0)