The box within reach of the couch: a Raspberry Pi 3B with the AIY Voice HAT, from the first household's configuration, made generic. - box/body: the button service, in Python: press and talk, turns by voice, a press interrupts; the look signal - box/*.js: the ir and look capabilities, behind gates, for the brain; the ask client, the box's side of a conversation - box/module.nix: the services, each confined to the devices and addresses it needs; the private network as an option (a tailnet by default); the Pico found by its USB IDs, as /dev/pdtv26-ir - box/voicehat.nix: the Voice HAT's device tree overlay and ALSA setup - lib.mkBox: a box's whole system from its name, the home server's, the Wi-Fi network's, and who looks after it - checks: box-js, box-py (doctests and pyflakes), and box-system (an example box's system evaluates) Generated-by: Claude Opus 5.5
50 lines
2.1 KiB
Nix
50 lines
2.1 KiB
Nix
# A box's whole system, from a few names: what lib.mkBox adds to the box's services.
|
|
# name the box's host name
|
|
# server the home server's name, where speech and the brain listen
|
|
# wifi the Wi-Fi network the box joins; its PSK goes on the card after imaging (make wifi-secret)
|
|
# admin who looks after the box, and logs in with sshKeys to deploy
|
|
{ name, server, wifi, admin, sshKeys }:
|
|
{ config, pkgs, ... }:
|
|
{
|
|
networking.hostName = name;
|
|
hardware.enableRedistributableFirmware = true; # the Pi 3B's Wi-Fi (brcmfmac)
|
|
|
|
pdtv26.box = {
|
|
enable = true;
|
|
speechUrl = "ws://${server}:8024/";
|
|
askUrl = "ws://${server}:8025/";
|
|
};
|
|
|
|
# Wi-Fi: the PSK stays out of the Nix store (it's world-readable).
|
|
networking.wireless = {
|
|
enable = true;
|
|
secretsFile = "/etc/wifi-secrets";
|
|
networks.${wifi}.pskRaw = "ext:psk";
|
|
};
|
|
# wpa_supplicant runs as its own user; its group number exists only after the first boot.
|
|
systemd.tmpfiles.rules = [ "z /etc/wifi-secrets 0640 root wpa_supplicant -" ];
|
|
|
|
services.avahi = { enable = true; nssmdns4 = true; publish = { enable = true; addresses = true; }; };
|
|
services.openssh = {
|
|
enable = true;
|
|
settings = { PasswordAuthentication = false; KbdInteractiveAuthentication = false; PermitRootLogin = "no"; };
|
|
};
|
|
users.users.${admin} = {
|
|
isNormalUser = true;
|
|
extraGroups = [ "wheel" "dialout" "audio" ]; # dialout: the Pico's serial port; audio: the Voice HAT
|
|
openssh.authorizedKeys.keys = sshKeys;
|
|
};
|
|
security.sudo.wheelNeedsPassword = false; # keys only; nixos-rebuild --target-host needs sudo
|
|
nix.settings.trusted-users = [ "@wheel" ];
|
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
|
|
|
zramSwap.enable = true; # 1 GB of RAM
|
|
boot.zfs.forceImportRoot = false; # no ZFS here; the 26.11 default, and quiet now
|
|
sdImage.compressImage = false;
|
|
|
|
# For make say, volume, and record, over ssh.
|
|
environment.systemPackages = [ pkgs.alsa-utils pkgs.espeak-ng ];
|
|
environment.etc."pdtv26-earcons".source = config.pdtv26.box.packages.earcons;
|
|
system.stateVersion = "26.05";
|
|
}
|