fixup! feat(box): the box's NixOS system as a module, and lib.mkBox from a few names

This commit is contained in:
dckc committed 2026-12-02 17:41:19 -06:00
1 parent 4dfff77b95
commit db174fc610
2 files changed
+11 -23

No files matched your search

-1
View File
@@ -3,5 +3,4 @@ __pycache__/
ir-pico/cache/ ir-pico/cache/
speech/cache/ speech/cache/
node_modules/ node_modules/
box/image
box/heard.wav box/heard.wav
+11 -22
View File
@@ -1,21 +1,20 @@
# box: the part of the agent within reach of the couch: a Raspberry Pi 3B with the AIY Voice HAT. # 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 # Tools come from the flake: nix develop --command make test
# #
# A box's system comes from lib.mkBox in a flake of your own (FLAKE), as nixosConfigurations.BOX. # A box's system, and so its image, come from lib.mkBox in your household's own flake: build the
# Build its image, write it to a card, put the Wi-Fi secret on it, boot the Pi: # image there (nix build), and deploy changes from there (nixos-rebuild). Here, the tools that take
# make image FLAKE=... BOX=... # 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 card DEV=/dev/sdX # look first
# make flash DEV=/dev/sdX CONFIRM=erase # then write # make flash DEV=/dev/sdX IMG=.../sd-image/x.img CONFIRM=erase # then write
# make wifi-secret SSID=... # make wifi-secret SSID=...
# After that, changes go over ssh: make deploy. Then, on the home server, as the brain's user, # Then, on the home server, as the brain's user,
# with speech and the brain installed: make keys. # with speech and the brain installed: make keys.
FLAKE = .
BOX = box BOX = box
ADMIN = $(USER) ADMIN = $(USER)
HOST = $(BOX).local HOST = $(BOX).local
NIX = nix --option extra-platforms aarch64-linux
DEV = DEV =
IMG =
SSID = SSID =
MNT = /mnt/pdtv26-card MNT = /mnt/pdtv26-card
TEXT = Hello. Press my button and talk to me. TEXT = Hello. Press my button and talk to me.
@@ -29,7 +28,7 @@ CAMERA_URL = $(HOME)/.config/pdtv26-camera/rtsp-url
SPEECH_KEY = /etc/pdtv26-speech/speech-key SPEECH_KEY = /etc/pdtv26-speech/speech-key
ON_BOX = ssh $(ADMIN)@$(HOST) ON_BOX = ssh $(ADMIN)@$(HOST)
.PHONY: help test image card flash wifi-secret deploy say volume record keys speech-key ask-key ir-key look-key rtsp-url .PHONY: help test card flash wifi-secret say volume record keys speech-key ask-key ir-key look-key rtsp-url
## list targets ## list targets
help: help:
@@ -39,31 +38,21 @@ help:
test: test:
nix build -L --no-link ..#checks.x86_64-linux.box-js ..#checks.x86_64-linux.box-py ..#checks.x86_64-linux.box-system nix build -L --no-link ..#checks.x86_64-linux.box-js ..#checks.x86_64-linux.box-py ..#checks.x86_64-linux.box-system
## BOX's SD card image (aarch64: under qemu, unless this is an aarch64 machine)
image:
$(NIX) build -L --out-link image '$(FLAKE)#nixosConfigurations.$(BOX).config.system.build.sdImage'
ls -l image/sd-image/
## show the card at DEV, and check it's removable, on USB, and under 128 GB ## show the card at DEV, and check it's removable, on USB, and under 128 GB
card: card:
./card-check.sh $(DEV) ./card-check.sh $(DEV)
## erase the card at DEV and write the image: make flash DEV=/dev/sdX CONFIRM=erase ## erase the card at DEV and write the image IMG to it: make flash DEV=/dev/sdX IMG=... CONFIRM=erase
# Not "flash: image": image links into the Nix store, where every mtime is 1970, so make would always rebuild.
flash: card flash: card
@test "$(CONFIRM)" = erase || { echo "this erases $(DEV); add CONFIRM=erase"; exit 1; } @test "$(CONFIRM)" = erase || { echo "this erases $(DEV); add CONFIRM=erase"; exit 1; }
@test -e image || { echo "no image yet: make image"; exit 1; } @test -f "$(IMG)" || { echo "which image? add IMG=.../sd-image/....img, from your household's nix build"; exit 1; }
./flash.sh image/sd-image/*.img $(DEV) ./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=... ## put the Wi-Fi network's PSK on the card, from the passphrase in the desktop keyring: make wifi-secret SSID=...
wifi-secret: wifi-secret:
@test -n "$(SSID)" || { echo "which network? add SSID=..."; exit 1; } @test -n "$(SSID)" || { echo "which network? add SSID=..."; exit 1; }
./wifi-secret.sh '$(SSID)' $(MNT) ./wifi-secret.sh '$(SSID)' $(MNT)
## build BOX's system here and switch the Pi to it, over ssh: make deploy [HOST=...]
deploy:
nixos-rebuild switch --flake '$(FLAKE)#$(BOX)' --target-host $(ADMIN)@$(HOST) --sudo --option extra-platforms aarch64-linux
## speak TEXT through the box's speaker, with espeak-ng: make say [TEXT="..."] [AMP=0..200] ## speak TEXT through the box's speaker, with espeak-ng: make say [TEXT="..."] [AMP=0..200]
say: say:
printf '%s\n' "$(TEXT)" | ssh $(ADMIN)@$(HOST) 'espeak-ng -a $(AMP) --stdin --stdout | aplay -q -D speaker' printf '%s\n' "$(TEXT)" | ssh $(ADMIN)@$(HOST) 'espeak-ng -a $(AMP) --stdin --stdout | aplay -q -D speaker'