Skip to content

Commit 60ab886

Browse files
committed
docs: harden nixos instructions
1 parent 2dfbb85 commit 60ab886

1 file changed

Lines changed: 49 additions & 14 deletions

File tree

docs/installation/nixos.md

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ Add this to your NixOS configuration (`/etc/nixos/configuration.nix`):
2727
services.ollama = {
2828
enable = true;
2929
acceleration = "cuda"; # or "rocm" for AMD, "cpu" for no GPU
30-
host = "0.0.0.0";
31-
openFirewall = true;
30+
host = "127.0.0.1";
3231
environmentVariables = {
3332
OLLAMA_KEEP_ALIVE = "1h";
3433
};
@@ -40,14 +39,14 @@ Add this to your NixOS configuration (`/etc/nixos/configuration.nix`):
4039
model = "large-v3";
4140
language = "en";
4241
device = "cuda"; # or "cpu" if no GPU
43-
uri = "tcp://0.0.0.0:10300";
42+
uri = "tcp://127.0.0.1:10300";
4443
};
4544
};
4645
4746
services.wyoming.piper.servers.default = {
4847
enable = true;
4948
voice = "en-us-ryan-high";
50-
uri = "tcp://0.0.0.0:10200";
49+
uri = "tcp://127.0.0.1:10200";
5150
};
5251
5352
services.wyoming.openwakeword = {
@@ -57,7 +56,7 @@ Add this to your NixOS configuration (`/etc/nixos/configuration.nix`):
5756
"hey_jarvis"
5857
"ok_nabu"
5958
];
60-
uri = "tcp://0.0.0.0:10400";
59+
uri = "tcp://127.0.0.1:10400";
6160
};
6261
}
6362
```
@@ -108,11 +107,13 @@ If you have an NVIDIA GPU, also add:
108107
3. **Install agent-cli:**
109108

110109
```bash
111-
nix-shell -p portaudio pkg-config gcc python3 --run "uv tool install --upgrade agent-cli"
110+
nix-shell -p portaudio pkg-config gcc uv --run 'uv tool install --upgrade agent-cli'
112111
# or add to your configuration:
113-
# environment.systemPackages = with pkgs; [ agent-cli ];
112+
# environment.systemPackages = with pkgs; [ uv portaudio pkg-config gcc ];
114113
```
115114

115+
This ensures the PortAudio development files and build toolchain are in scope while `uv` installs PyAudio.
116+
116117
4. **Test the setup:**
117118
```bash
118119
agent-cli autocorrect "this has an eror"
@@ -127,6 +128,8 @@ If you have an NVIDIA GPU, also add:
127128
| **Piper** | 10200 | N/A | `wyoming-piper.service` |
128129
| **OpenWakeWord** | 10400 | N/A | `wyoming-openwakeword.service` |
129130

131+
> By default all services bind to `127.0.0.1`, keeping them accessible only from the local machine.
132+
130133
## Service Management
131134

132135
```bash
@@ -163,9 +166,9 @@ sudo systemctl --failed
163166
journalctl -u ollama --since "1 hour ago"
164167
```
165168

166-
### Firewall Issues
169+
### Firewall & Remote Access
167170

168-
Make sure `openFirewall = true` is set for each service, or manually add:
171+
Binding to `127.0.0.1` means no firewall changes are required. If you explicitly need LAN access, switch the host/URIs back to `0.0.0.0` and either set `openFirewall = true` on each service or add:
169172

170173
```nix
171174
{
@@ -175,6 +178,19 @@ Make sure `openFirewall = true` is set for each service, or manually add:
175178
}
176179
```
177180

181+
Only open these ports on networks you trust.
182+
183+
### PyAudio Build Errors
184+
185+
If an earlier install attempt mixed Python versions, `uv` may leave behind an incompatible environment (common error: `would build wheel with unsupported tag ('cp311', 'cp313', ...)`). Clean the cached tool and reinstall:
186+
187+
```bash
188+
rm -rf ~/.local/share/uv/tools/agent-cli ~/.cache/uv/builds-v0
189+
nix-shell -p portaudio pkg-config gcc uv --run 'uv tool install --upgrade agent-cli'
190+
```
191+
192+
> The `rm -rf` command permanently deletes the cached environment—use it only when the install keeps failing.
193+
178194
## Configuration Example
179195

180196
Complete example from [basnijholt/dotfiles](https://github.com/basnijholt/dotfiles/blob/main/configs/nixos/configuration.nix):
@@ -185,8 +201,7 @@ Complete example from [basnijholt/dotfiles](https://github.com/basnijholt/dotfil
185201
services.ollama = {
186202
enable = true;
187203
acceleration = "cuda";
188-
host = "0.0.0.0";
189-
openFirewall = true;
204+
host = "127.0.0.1";
190205
environmentVariables = {
191206
OLLAMA_KEEP_ALIVE = "1h";
192207
};
@@ -198,24 +213,44 @@ Complete example from [basnijholt/dotfiles](https://github.com/basnijholt/dotfil
198213
model = "large-v3";
199214
language = "en";
200215
device = "cuda";
201-
uri = "tcp://0.0.0.0:10300";
216+
uri = "tcp://127.0.0.1:10300";
202217
};
203218
};
204219
205220
services.wyoming.piper.servers.default = {
206221
enable = true;
207222
voice = "en-us-ryan-high";
208-
uri = "tcp://0.0.0.0:10200";
223+
uri = "tcp://127.0.0.1:10200";
209224
};
210225
211226
services.wyoming.openwakeword = {
212227
enable = true;
213228
preloadModels = [ "alexa" "hey_jarvis" "ok_nabu" ];
214-
uri = "tcp://0.0.0.0:10400";
229+
uri = "tcp://127.0.0.1:10400";
215230
};
216231
}
217232
```
218233

234+
## Optional: Keep `agent-cli server` Running
235+
236+
To mirror this repository's working configuration, add a user service that keeps the FastAPI server alive:
237+
238+
```nix
239+
systemd.user.services."uvx-agent-cli" = {
240+
description = "uvx agent-cli server";
241+
wantedBy = [ "default.target" ];
242+
path = [ pkgs.ffmpeg pkgs.uv ];
243+
serviceConfig = {
244+
ExecStart = "${pkgs.uv}/bin/uvx agent-cli server";
245+
Restart = "always";
246+
RestartSec = 5;
247+
WorkingDirectory = "/home/your-user";
248+
};
249+
};
250+
```
251+
252+
Adjust `WorkingDirectory` for your username/home path.
253+
219254
## Alternative: Script-Based Setup
220255

221256
If you prefer not to use system services, you can also use the [regular Linux scripts](linux.md) on NixOS.

0 commit comments

Comments
 (0)