Runs on a Raspberry Pi Zero 2W. Hosts a local webserver that accepts & stores AQI readings (on attached drive) and graphs it. Network storage w/ Samba share which automounts attached USB drives and integrates with my my desktop flake for weekly reminders to sync data from this share.
Also has daily systemd tasks which make backups of private Github repos & downloads Spotify playlists and is easily accessible with a network-wide Avahi .local resolve shorthand.and.
Add cross compiling support to your host Nix config: boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
Rebuild your host and set /home/alec/GithubToken to a PAT to back up private Github repos.
nix run nixpkgs#nixos-generators -- -f sd-aarch64 --flake .#alechomelab --system aarch64-linux -o ./alechomelabsd
sudo cp alechomelabsd/sd-image/nixos-image-sd-card--hash here>gt;-aarch64-linux.img.zst ./alechomelabsd-compressed-sd-image.img.zst
unzstd -d alechomelabsd-compressed-sd-image.img.zst -o alechomelabsd-sd-image.img
sudo dd if=./alechomelabsd-sd-image.img of=/dev/sdX bs=1M status=progressess The image will only partition about 4GB of the card, so use udisks to resize the main partition to use the whole card. I recommend using an 8GB or 16GB card - larger cards can slow the system down and isn't used for file storage.
Default login is user alec password nixos (use passwd alec to change)
Set AIRNOW_TOKEN= in webserver/.env for Airnow.gov data to work
Paste your Github auth token to /home/alec/GithubToken
Set the Samba user password: sudo smbpasswd -a alec
Update the client key and secret to use your own from the Spotify developer dashboard. in /home/alec/.config/spotdl/config.json. If you get a rate limit error, enable the no_cache option.
Use remote deployments to update since the Zero 2W doesnt have enough memory to build itself: nixos-rebuild switch --flake .#alechomelab --sudo --ask-sudo-password --target-host [email protected]
Replace the config.txt file in the Pi's FIRMWARE partition with:
# For proper boot
kernel=u-boot-rpi3.bin
arm_64bit=1
enable_uart=1
1
# Turn on spi & i2c and gpio buttonstons
dtparam=spi=on
dtparam=i2c_arm=on
gpio=6,19,5,26,13,21,20,16=pu
u
# Disable hdmi output
gpu_mem=16
disable_fw_kms_setup=1
disable_overscan=1
hdmi_force_hotplug=0
hdmi_blanking=2
g=2
# Faster boot
boot_delay=0
disable_splash=1
avoid_warnings=1s=1I've made a simple model for the base of the Pi. I'm using this acrylic kit which I acquired from Daydream Seattle. The model is available here.
Use the nix devshell to install gcc & the libraries for the program on your computer: er: cd display && nix develop develop and make
Run cd display && nix-shell -p gcc gnumake libgpiod_1bgpiod_1 and make to build the program on the Pi.
You can run the ./homelabDisplay binary in /home/alec/homelab/display/ or reboot to start the program.
Note that you will need GPIO header pins and this 1.44in Waveshare HAT to use the display program.