Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Ormolu via Nix #431

Open
aspiwack opened this issue Oct 24, 2022 · 6 comments
Open

Provide Ormolu via Nix #431

aspiwack opened this issue Oct 24, 2022 · 6 comments

Comments

@aspiwack
Copy link
Member

Ormolu has very slow to build dependencies (essentially ghc-lib-parser). This has been an obstacle to contributing, and makes the CI very slow on the first push of a new branch.

Currently, the ./format script build Ormolu itself, via stack build. This is convenient (calling ./format is machine independent). The main reason why we went this route back then, was that the version of Ormolu that was available on Nixpkgs was too old, we needed a recent one. Now, I believe that it should be easy to provide Ormolu via Nixpkgs.

This doesn't prevent contributors who want to provide Ormolu via Stack to call stack build ormolu && stack exec -- ./format. It makes the management of dependencies more package-manager agnostic. And will let us download cached Ormolu when using Nix (in particular on CI).

@endgame
Copy link
Contributor

endgame commented Dec 14, 2022

I happened to want a recent ormolu from nixpkgs in some other place, and I found that I had to do this with ghc-9.2.5 to get a recent enough ghc-lib-parser (which meant rebuilding ghc-lib-parser again):

    ormolu = (prev.haskell.packages.ghc925.override {
      overrides = hfinal: hprev: with prev.haskell.lib; {
        ormolu = hprev.generateOptparseApplicativeCompletions [ "ormolu" ]
          (enableSeparateBinOutput hfinal.ormolu_0_5_0_1);
      };
    }).ormolu.bin;

So ormolu-from-nixpkgs may not dodge the ghc-lib-parser build.

@aspiwack
Copy link
Member Author

Indeed, I've noticed something like this in a project of mine recently.

But for CI at least, we can workaround this by setting up a Cachix cache. Which doesn't have the issue that Github actions seem to have that the first build on a PR doesn't use the cache (or maybe that's an issue with our configuration, but I've checked and it looks good. Obviously I may have missed something and there may be an easy solution, it would be great in the short term).

@mrkkrp
Copy link
Member

mrkkrp commented Dec 15, 2022

Why don't you just use https://github.com/mrkkrp/ormolu-action ?

@tbagrel1
Copy link
Member

@mrkkrp
AFAIR, we wanted for the same ormolu version to be provided both to the user and to the CI. Which the github action wouldn't help to do, right?

@mrkkrp
Copy link
Member

mrkkrp commented Dec 15, 2022

Depends on how badly you want this and whether you want to make a compromise. I usually just use the same ormolu I have on my system for all formatting, and I don't particularly care about its version. I use the GitHub action for all projects on CI. The advantage is that the CI setup is very simple and acts as the definite source of truth, which is all I want. In all my projects it's been really rare, if ever, that my system ormolu would format differently from the CI version. In 99.99% of cases you won't have to reformat, and the benefit is simplicity and reliability.

@tbagrel1
Copy link
Member

I'll let @aspiwack decide then :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants