How to convert raspberry pi 4 to btrfs?

I followed the nixos wiki to install rpi4 about a year ago, which pointed me to this website to install the image.
It is the image with nixos preinstalled with ext4 filesystem.

I am happy with that until recently the nixos-rebuild switch keep failing, and it is caused by all the 8GB ram filled up with 3 build jobs, and there is no swap partition on the disk.

I want to change the filesystem to btrfs and then add a swap subvolume to update the machine. How can I do that? Thanks!