on: workflow_dispatch: env: NIX_CONFIG: | extra-substituters = https://attic.radiantwavetech.com/radiantwave https://nixos-raspberrypi.cachix.org extra-trusted-public-keys = radiantwave:QADrjpBWJssTZ3KmiZtcWEf4uAm66oOlHmtQI3jkrgA= nixos-raspberrypi.cachix.org-1:4iMO9LXa8BqhU+Rpg6LQKiGa2lsNh/j2oiYLNOQ5sPI= jobs: build-rpi: runs-on: orion-lxc steps: - name: Checkout run: git clone --depth 1 ssh://git@gitea.radiantwavetech.com:2222/RadiantWaveTech/KioskConfig.git . - name: Guard main branch is on the production channel run: | . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh NAME=$(nix eval --impure --raw .#channelName) if [ "$NAME" != "radiantwave" ]; then echo "ERROR: main branch resolves to the '$NAME' channel, expected 'radiantwave'." echo " A dev->main merge brought a dev-pointing channel block into flake.nix." echo " Set channel.appInput/atticRepo/gitRef back to main values before building prod images." exit 1 fi # Fail fast unless the closure baked into the image is exactly what # RadiantWave CI published to Attic (aarch64). Otherwise the Pi compiles # RadiantWave from source (slow) unless RadiantWave CI has published both # the aarch64 closure and aarch64-manifest.json. See `channel` in flake.nix. - name: Verify baked baseline matches the published channel run: | set -euo pipefail . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh VERSION=$(nix eval --impure --raw .#channelVersion) ATTIC=$(nix eval --impure --raw .#channelAtticUrl) MANIFEST_URL="$(nix eval --impure --raw .#channelManifestDir)/aarch64-manifest.json" BASELINE=$(nix eval --impure --raw .#baselineOutPaths.aarch64-linux) MANIFEST=$(curl -fsSL "$MANIFEST_URL") PUB_VERSION=$(MANIFEST="$MANIFEST" nix eval --impure --raw --expr '(builtins.fromJSON (builtins.getEnv "MANIFEST")).version') PUB_PATH=$(MANIFEST="$MANIFEST" nix eval --impure --raw --expr '(builtins.fromJSON (builtins.getEnv "MANIFEST")).storePath') echo "channel version : $VERSION" echo "manifest version: $PUB_VERSION" echo "baseline path : $BASELINE" echo "manifest path : $PUB_PATH" if [ "$VERSION" != "$PUB_VERSION" ]; then echo "ERROR: channel.appVersion '$VERSION' != published manifest version '$PUB_VERSION'." echo " Bump channel.appVersion (and the pinned radiantwave input) to match the release." exit 1 fi if [ "$BASELINE" != "$PUB_PATH" ]; then echo "ERROR: baseline '$BASELINE' is not the published closure '$PUB_PATH'." echo " Run 'nix flake update radiantwave' so the pinned input resolves to the release the manifest was built from." exit 1 fi HASH=$(basename "$BASELINE" | cut -d- -f1) if ! curl -fsS -o /dev/null "$ATTIC/${HASH}.narinfo"; then echo "ERROR: $BASELINE is not in $ATTIC; the image would compile RadiantWave from source." exit 1 fi - name: Prepare output directory run: mkdir -p /var/lib/gitea-runner/radiantwave - name: Build Raspberry Pi image run: | export NIXPKGS_ALLOW_UNFREE=1 . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh nix build -L --impure .#nixosConfigurations.radiantwavekiosk-rpi.config.system.build.sdImage - name: Rename Raspberry Pi image run: | ISO_DATE=$(date +%Y-%m-%d_%H-%M-%S) FILENAME="radiantwave-rpi-${ISO_DATE}.img.zst" cp -L result/sd-image/*.img.zst "/var/lib/gitea-runner/radiantwave/${FILENAME}" echo "RPI_IMAGE_FILENAME=${FILENAME}" >> "$GITHUB_ENV" - name: Copy Raspberry Pi image to fileserver run: | scp "/var/lib/gitea-runner/radiantwave/${RPI_IMAGE_FILENAME}" \ 157.245.124.103:/mnt/infrastructure_data/files/images/ - name: Cleanup Raspberry Pi image run: rm -f "/var/lib/gitea-runner/radiantwave/${RPI_IMAGE_FILENAME}"