Self-assembly of nanostructures