PI Zero W - Set WiFi Parameters for headless operation

Hi all,
I'm planning to setup a Pi Zero W as a Bridge for a ZeroTier network. To do this I'm planning to install OpenWRT on the PI0W, then hook it up to the ZeroTier networks as a bridge device. Sofar so good.

Now the triky bit: Is it possible to configure the WiFi parameters before I boot the device?
This is possible with Raspberry OS (Raspbian), by adding a file, "wpa_supplicant.conf", to the /boot [FAT32] on the SD-Card (and add an empty file called "ssh", to enable ssh after booting).

p.s.
This is what the wpa_supplicant.conf file looks like:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE

network={
 ssid="mySSID"
 psk="##myWiDiPassword##"
 id_str="XXX"
}

/etc/config/wireless is generated on firstboot conditions of OpenWrt, its contents depend on the detected wireless hardware. While I don't know about its structure (the necessary device path and maybe MAC addresses) on this particular hardware, you can fetch it from a working/ fully configured RPi-0W once and then re-use it afterwards (at least for the same major OpenWrt version).

--
injecting files into ext4 based images would be easier than properly initializing an overlay on top of squashfs outside of the firstboot environment.

@yonz2 Are you aware of the "image builder"? This is precisely what it can be used for.

For example to generate a RPi image:

#!/bin/bash

#Documentation: https://openwrt.org/docs/guide-user/additional-software/imagebuilder

OUTPUT="$(pwd)/images"
BUILDER="https://downloads.openwrt.org/releases/21.02.0/targets/bcm27xx/bcm2708/openwrt-imagebuilder-21.02.0-bcm27xx-bcm2708.Linux-x86_64.tar.xz"

# download image builder
if [ ! -f "${BUILDER##*/}" ]; then
	wget "$BUILDER"
	tar xJvf "${BUILDER##*/}"
fi

mkdir "$OUTPUT"
cd openwrt-*/

# list all targets for this image builder, consider 'make help' as well
# make info

# clean previous images
make clean

make image  PROFILE="rpi" \
           PACKAGES="luci-base luci-ssl luci-mod-admin-full luci-theme-bootstrap" \
            BIN_DIR="$OUTPUT"

You need to add the files by creating a folder and add all those files to the root of the SD-card with make image FILES="<path>" # include extra files from <path> as explained at https://openwrt.org/docs/guide-user/additional-software/imagebuilder

Add your WiFi parameters after OpenWRT creates the /etc/config/wireless by creating a script that waits for that file, modifies the contents and triggers a wifi restart or reboot.

HTH!

Edit: instead of adding a script there is the intended option with "uci-defaults". Basically it needs steps very similar to this: https://openwrt.org/docs/guide-user/installation/flashing_openwrt_with_wifi_enabled_on_first_boot