Including Directories with a Haskell Source Distribution

When creating a Haskell source distribution with Cabal/Stack sdist, you may want to include extra directories for various reasons. This is unfortunately quite difficult to do.

The necessary cabal field is extra-source-files. However, you can't just include your directories as you would expect. For example, the following won't work:

extra-source-files:
    directory1/
    directory2/
    directory3/

Instead, you need to specify the exact glob you want:

extra-source-files:
    directory1/*.hs
    directory2/*.txt
    directory3/anotherDirectory1/*.hs

This isn't really the expected behaviour. However, as explained by the a #haskell chat, the implementation is a bit tricky to get right.

Rather than use Distribution.Simple.postSDist, or create a script, I hard coded my directories. It's the simplest solution available right now.

Something wrong? Please raise an issue.