# Setting up the agent at the TV You'll need the [parts](../README.md#parts), a Linux home server with Nix and systemd, a private network both it and the box can join (Tailscale, by default), and an afternoon. The steps below are in the order they depend on each other. Each `make` target says more with `make help`. ## 1. Make a repository for your household A private git repository of your own holds what's yours: the names you choose, and later who the brain serves. None of that belongs in pdtv26. Its `flake.nix`: ```nix { inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; inputs.pdtv26 = { url = "git+https://git.inference.coop/dckc/pdtv26"; inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { pdtv26, ... }: { nixosConfigurations.pimote = pdtv26.lib.mkBox { name = "pimote"; # the box's host name on your network server = "den-pc"; # your home server's host name: speech and the brain wifi = "MyNetwork"; # your Wi-Fi network's name (SSID), spelled exactly admin = "pat"; # who looks after the box, and logs in to deploy sshKeys = [ "ssh-ed25519 AAAA... pat@laptop" ]; }; }; } ``` Ports have defaults, and the box finds the IR emitter by its USB IDs. Anything else about the box's system goes in `modules = [ ./household.nix ]`, alongside: a status page (`pdtv26.box.statusUrl`), another Wi-Fi network, another private network (`pdtv26.box.network`), or no camera (`pdtv26.box.look.enable = false`). ## 2. Set up the home server Any Linux with systemd and [Nix](https://nixos.org/download/) will do; it needn't be NixOS. Clone pdtv26 there, then: 1. `sudo make -C speech install`: the speech server, its models (about 200 MB), its key, and its systemd unit. 2. `sudo make -C status install BOX=pimote`: the status page, if you want one. The brain comes after the box, in step 5, since it needs the box's keys. ## 3. Make the box's SD card On any Linux machine with Nix that can run ARM programs (on Debian or Ubuntu, `apt install qemu-user-static`), in pdtv26's `box/`: 1. `make image FLAKE=path/to/household BOX=pimote`, then `make card DEV=/dev/sdX` to check you have the right device, and `make flash DEV=/dev/sdX CONFIRM=erase`. 2. `make wifi-secret SSID=MyNetwork`: it puts the network's PSK on the card from the passphrase in your desktop keyring, not in the image or the repository. Store the passphrase there once, with `secret-tool store --label="Wi-Fi MyNetwork" service wifi ssid MyNetwork`. 3. Put the card in the Pi, plug in the IR emitter's USB cord, and power it up. After this, changes to the box go over ssh: `make deploy FLAKE=path/to/household BOX=pimote`. ## 4. Join the private network On the box and the home server: `tailscale up`, or whatever private network you use. ## 5. Make the keys, and start the brain On the home server, as the user the brain will run as, in pdtv26's `box/`: 1. `make keys BOX=pimote ADMIN=pat`: one key per connection, piped to both its ends; the box's ir and look keys come back for the brain. Put the camera's RTSP URL in `~/.config/pdtv26-camera/rtsp-url` first, or skip `rtsp-url`. 2. Make a fine-grained GitHub token for one repository, Issues read/write only, for problem reports, and save it as `~/.config/pdtv26-brain/report-token`. 3. `make -C ../brain install BOX=pimote REPO=you/your-repo ASSIGNEE=you`, then `make -C ../brain attach` once: log in, trust the folder, and approve the box's channel. ## 6. Tell it who it's for The brain reads `~/pdtv26-brain/household.md`: who looks after it, who it serves, what they like to watch, what to be patient about. `make install` puts an example there; make it yours, and keep it in your household repository. ## 7. Teach it your remotes Press the button and ask: "Learn my TV's power button." Point the TV's remote at the IR emitter and press **Power** when it asks. Do the same for **Input**, the cable box, and the rest. It keeps what it learns in its notes.