NixOS configuration for a Raspberry Pi 3 IR transmitter controllable using MQTT.
The following instructions are specific to NixOS. It might be possible to build it on other platforms (as long as they have nix installed) but I haven't tried.
You should emulate aarch64 rather than cross-compiling it. Emulation will allow you to use NixOS's binary cache, which is much faster than compiling everything. Add the following options to your system's configuration.nix (and run nixos-rebuild switch afterwards):
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
nix.settings.extra-platforms = [ "aarch64-linux" "arm-linux" ];Wifi credentials are configured using the following environment variables:
WIFI_SSIDWIFI_PSK
The .envrc in this repo configures direnv to read .env. Add a .env file that looks like this:
WIFI_SSID="..."
WIFI_PSK="..."These credentials will be set as global environment variables in the resulting NixOS installation. The build will fail if they are unset.
-
Build the sd card image by running
make
-
Install the image on a SD card
sudo dd if=./result/sd-image/nixos-sd-image-irberry.img of=/dev/sda bs=4096 conv=fsync
-
Put the SD card into the raspberry pi and start it up!
-
It'll take a minute or two for it to start, but once it's up and running change the password
# initial password is 'changeme' ssh matt@<ip-address> passwd
-
The raspberry pi should now be connected to the MQTT broker and sending IR signals when commands are sent to the topic
irberry/button!
-
sshinto the raspberry pissh matt@<ip-address>
-
Update nix channels
sudo nix-channel --update
-
Run
nixos-rebuild switch, but be sure to open a root shell so the environment variables are set properlysudo bash nixos-rebuild switch