Since macOS Catalina, the root drive is read-only. The solution is to create a separate APFS volume and a “synthetic” /nix directory which points to it:
# Check if /nix exists, if not:
echo 'nix' | sudo tee -a /etc/synthetic.conf
# this will create a "synthetic" empty directory /nix
# REBOOT so macOS sees the synthetic directory
# After rebooting, create an APFS volume for Nix