This will likely work with most systemd based Linux distribution using systemd-networkd
Watch out for
Prepare the SD card using RPI imager - mount the resulting root partition on the SD card.
Edit the file as root
$MOUNTPOINT/etc/wpa_supplicant/wpa_supplicant.conf
Append the following and save the file
....
network={
ssid="apname"
psk="pskvalue or cleartext passphrase"
}
Edit the file as root
$MOUNTPOINT/etc/network/interfaces
Append the following and save the file
....
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Source Raspberry Pi wpa_cli