Convert list of strings of absolute paths to source directory

What’s the best way to convert a list of absolute paths as strings like:

[ "/foo/" "/foo/" "/foo/docs/" ]

…to a source directory (in the spirit of builtins.path and company) where each file would get copied to /nix/store under a directory like /nix/store/abc123-source/{foo/,foo/,foo/docs/}.

The best practice is probably not to end up with such a list in the first place.

What’s your use case? It looks like there must almost certainly be a better way of doing this, the files are all ij the same top level directory.