This should be possible by looking for a [`custom-setup`](https://cabal.readthedocs.io/en/3.4/cabal-package.html#custom-setup-scripts) stanza in the `.cabal` file. See: https://github.com/gentoo-haskell/gentoo-haskell/issues/1327