tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
955 stars 83 forks source link

Make example files optional #682

Closed hololeap closed 3 years ago

hololeap commented 3 years ago

This package was called to my attention via parsonsmatt/fourmolu#59 .

It would be nice to have a way to toggle the example files since there are so many. Unfortunately, there's no way to toggle data-files in a cabal file using a flag, but one idea is to move them to a separate ormolu-examples package.

mrkkrp commented 3 years ago

What is problematic about packaging the examples?

hololeap commented 3 years ago

It's ~700 extra files on the system that aren't necessarily needed or desired, especially if ormolu is being installed because it's a dependency for something else, for instance haskell-language-server.

hololeap commented 3 years ago

I am working on packaging haskell-language-server for Gentoo, and doing so requires packaging all hard and optional dependencies for it. Generally, with Gentoo, we give packages like this an examples flag so that the user can install them if they desire, but don't have to. Currently, my solution is to conditionally patch ormolu.cabal to remove the data-files unless the examples flag in Gentoo is set. But that solution is less elegant and harder to maintain than something done through cabal. (Another option is to remove the files on the system after they've been copied over, which seems wasteful as a permanent solution.)

Part of the problem is that data-files cannot be toggled with a flag in cabal, which would be the most straightforward solution. Others that I asked recommended the example files be moved to a separate package, but I'm totally open to other ideas.

georgefst commented 3 years ago

If it's about disk space, it's worth noting that the example files come to 3MB. On my system, the Ormolu binary is 23MB, and HLS is 171MB.

On the other hand, I don't know what's actually gained by having these under data-files - I don't think they're used at runtime or anything.

mrkkrp commented 3 years ago

I maintain about 30 Haskell packages. Unless there is a real technical problem with having those data-files included, I'm not going to split Ormolu into two packages.

I don't know what's actually gained

What is gained by the current packaging is convenience, but it's not clear what is lost.

hololeap commented 3 years ago

but it's not clear what is lost

Flexibility and user control over what is installed?

Again, I'm not forcing the issue of splitting ormolu into two packages. Any solution that makes the example files optional and not forcibly installed by cabal would be fine.

mrkkrp commented 3 years ago

Okay, let me put it differently. What actual harm comes from having 3 Mb of examples bundled with Ormolu? Is Ormolu the most bloated piece of software on your system? I'm sure that it is rather benign compared to others. If it's about disk space, then what other problem are you trying to solve? Flexibility is good only when it serves a purpose.

ezzieyguywuf commented 3 years ago

I like the idea of making this an option - when I install a piece of software on my computer, I like to minimize its footprint unless I explicitly need more.

For starters, this will make my daily backup diff less polluted, and easier to parse.

More importantly though, and aside from the disk space conversation, it reduced my overall exposure for malicious "whatever". The less files I allow a package to install, the less likely I am to get something shifty.

hololeap commented 3 years ago

@mrkkrp It isn't so much a problem that needs to be fixed as much as an enhancement that allows users to choose if they want the example files on their system.

I understand that you don't want to maintain another package and that the reward for this enhancement is low. I'm currently looking for a solution that will allow for this flexibility while keeping the current level of convenience for you. If we can't come to a compromise, then I will continue using the current solution available in Gentoo.

amesgen commented 3 years ago

I don't know how Haskell apps are packaged in Gentoo, but would it help if ormolu would use extra-source-files instead of data-files? For comparison, dhall also uses extra-source-files to include its test files.