feat(box): the box's NixOS system as a module, and lib.mkBox from a few names
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
This commit is contained in:
1 parent
2e7156dc36
commit
190600a696
35 files changed
+2152
-3
No files matched your search
@@ -0,0 +1,58 @@
|
||||
# box: the part of the agent within reach of the couch: a Raspberry Pi 3B with the AIY Voice HAT.
|
||||
# Tools come from the flake: nix develop --command make test
|
||||
#
|
||||
# A box's system, and so its image, come from lib.mkBox in your household's own flake: build the
|
||||
# image there (nix build), and deploy changes from there (nixos-rebuild). Here, the tools that take
|
||||
# no household details: write the image to a card, put the Wi-Fi secret on it, boot the Pi:
|
||||
# make card DEV=/dev/sdX # look first
|
||||
# make flash DEV=/dev/sdX IMG=.../sd-image/x.img CONFIRM=erase # then write
|
||||
# make wifi-secret SSID=...
|
||||
|
||||
BOX = box
|
||||
ADMIN = $(USER)
|
||||
HOST = $(BOX).local
|
||||
DEV =
|
||||
IMG =
|
||||
SSID =
|
||||
MNT = /mnt/pdtv26-card
|
||||
TEXT = Hello. Press my button and talk to me.
|
||||
AMP = 100
|
||||
VOL = 30%
|
||||
SECS = 6
|
||||
|
||||
.PHONY: help test card flash wifi-secret say volume record
|
||||
|
||||
## list targets
|
||||
help:
|
||||
@awk -f ../make-help.awk $(MAKEFILE_LIST)
|
||||
|
||||
## the unit tests and doctests, and that a box's system evaluates, in Nix's build sandbox
|
||||
test:
|
||||
nix build -L --no-link ..#checks.x86_64-linux.box-js ..#checks.x86_64-linux.box-py ..#checks.x86_64-linux.box-system
|
||||
|
||||
## show the card at DEV, and check it's removable, on USB, and under 128 GB
|
||||
card:
|
||||
./card-check.sh $(DEV)
|
||||
|
||||
## erase the card at DEV and write the image IMG to it: make flash DEV=/dev/sdX IMG=... CONFIRM=erase
|
||||
flash: card
|
||||
@test "$(CONFIRM)" = erase || { echo "this erases $(DEV); add CONFIRM=erase"; exit 1; }
|
||||
@test -f "$(IMG)" || { echo "which image? add IMG=.../sd-image/....img, from your household's nix build"; exit 1; }
|
||||
./flash.sh '$(IMG)' $(DEV)
|
||||
|
||||
## put the Wi-Fi network's PSK on the card, from the passphrase in the desktop keyring: make wifi-secret SSID=...
|
||||
wifi-secret:
|
||||
@test -n "$(SSID)" || { echo "which network? add SSID=..."; exit 1; }
|
||||
./wifi-secret.sh '$(SSID)' $(MNT)
|
||||
|
||||
## speak TEXT through the box's speaker, with espeak-ng: make say [TEXT="..."] [AMP=0..200]
|
||||
say:
|
||||
printf '%s\n' "$(TEXT)" | ssh $(ADMIN)@$(HOST) 'espeak-ng -a $(AMP) --stdin --stdout | aplay -q -D speaker'
|
||||
|
||||
## set the box's speaker volume (the softvol in front of the amp): make volume [VOL=30%]
|
||||
volume:
|
||||
ssh $(ADMIN)@$(HOST) 'aplay -q -D speaker -f S16_LE -d 1 /dev/zero; amixer -q -c voicehat sset speaker $(VOL) && amixer -c voicehat sget speaker | tail -1'
|
||||
|
||||
## chime, then record SECS seconds from the box's mics to heard.wav (32-bit stereo, 16 kHz)
|
||||
record:
|
||||
ssh $(ADMIN)@$(HOST) 'aplay -q -D speaker /etc/pdtv26-earcons/open.wav && arecord -q -D hw:CARD=voicehat,DEV=0 -f S32_LE -c 2 -r 16000 -d $(SECS) -t wav -' > heard.wav
|
||||
Reference in new issue
Block a user