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

Bump to ghc 9.6.6 from Nix latest #1137

Merged
merged 16 commits into from
Jan 5, 2025

Conversation

morucci
Copy link
Collaborator

@morucci morucci commented Jan 3, 2025

First tentative to move our Haskell stack to a higher and stable version of the stack. We rely on podenv/hspkgs to provide a nix derivation for a Haskell package set.

Here we attempt a bump to hspkgs for ghc 9.6.4.

@TristanCacqueray
Copy link
Contributor

Hey @morucci , we shouldn't need hspkgs anymore, ghc-9.6 is now well established in nixpkgs. Let's remove that dependency and import the few overrides that are still needed. I think it should mostly work, though we need to fix the paths for the tools like weeder/hlint/fourmolu, which were provided as hspkgs.$tool where nixpkkgs provide them as pkgs.haskellPackages.$tool.

@TristanCacqueray
Copy link
Contributor

TristanCacqueray commented Jan 3, 2025

I remember doing that, but then a go package failed to build because the infrastructure change a bit. So let's replace the hspkgs import with github:NixOS/nixpkgs/d3780c92e64472e8f9aa54f7bbb0dd4483b98303 (which is the latest from https://github.com/NixOS/nixpkgs/tree/haskell-updates) to avoid updating the non-haskell things. Later we can fix the rest of the build to only pull a single nixpkgs.

In particular, we need to change:

hsPkgs = hspkgs.hspkgs.extend haskellExtend;

Into

hsPkgs = latestNixpkgs.haskellPackages.extend haskellExtend;

And then pull the overrides (e.g. gerrit) in

monocle/nix/default.nix

Lines 21 to 22 in 2246940

# Add monocle and patch broken dependency to the haskell package set
haskellExtend = hpFinal: hpPrev: {

@morucci
Copy link
Collaborator Author

morucci commented Jan 3, 2025

Hey @TristanCacqueray thanks for the guidance. I'll try to address that path in followup commits inside that PR. I understand that we'll have a bit of delay using nix to benefit latest Haskell tool chains. So yes if 9.6 and its dependencies are now well integrated in nixpkgs then let's try to use it directly.

@TristanCacqueray
Copy link
Contributor

TristanCacqueray commented Jan 3, 2025

It's not really because of nix, it's actually stackage which govern the set of "stable" versions. I think the default (9.6) should be fine, but you can try a more recent version by replacing pkgs.haskellPackages with pkgs.haskell.ghc910 for example.

Checkout how it was done to pull ghc9.6 when the default was 8.10: https://github.com/podenv/hspkgs/blob/7a46854f28ab9b99c51353c81d5967f1f6fd9a9b/flake.nix#L148

@morucci morucci changed the title Bump hspkgs for ghc 9.6.4 Bump to ghc 9.6.6 from Nix latest Jan 3, 2025
@TristanCacqueray
Copy link
Contributor

It's odd that the formatting changed, are you using?

(use-package nix-mode
  :config
  ;; auto format with nixfmt by default
  (reformatter-define nixfmt-format
    :program "nixfmt")
  (add-hook 'nix-mode-hook 'nixfmt-format-on-save-mode))

With nix profile install nixpkgs#nixfmt

nix/default.nix Outdated Show resolved Hide resolved
nix/default.nix Outdated Show resolved Hide resolved
@morucci
Copy link
Collaborator Author

morucci commented Jan 5, 2025

Looks like the effectful requirement in cabal is not compatible anymore because of effectful being 2.3.1 in the Nix set.

@TristanCacqueray
Copy link
Contributor

TristanCacqueray commented Jan 5, 2025

@morucci
Copy link
Collaborator Author

morucci commented Jan 5, 2025

(use-package nix-mode
  :config
  ;; auto format with nixfmt by default
  (reformatter-define nixfmt-format
    :program "nixfmt")
  (add-hook 'nix-mode-hook 'nixfmt-format-on-save-mode))

No, I was using the default nix-mode-format function. Now using your config, I'm getting the autoformat with nixfmt at save, and looks like it reverted to the initial format.

@morucci
Copy link
Collaborator Author

morucci commented Jan 5, 2025

Should be fine to use according to https://github.com/haskell-effectful/effectful/blob/master/effectful-core/CHANGELOG.md#effectful-core-2310-2024-06-07 and https://github.com/haskell-effectful/effectful/blob/master/effectful/CHANGELOG.md#effectful-2310-2024-06-07 . Let's bump the bound in monocle.cabal

This seems to cause issue with withEffToIO. Let's see the CI result.

@TristanCacqueray
Copy link
Contributor

Almost there, try to add SeqUnlift to the first param of withEffToIO

nix/default.nix Outdated
@@ -231,8 +245,8 @@ in rec {
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That reformat seems wrong, you'll have to manually discard all these chunks.

Copy link
Collaborator Author

@morucci morucci Jan 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did a drop of both formating commits. Then re-run the nixfmt (this is the last commit here). That looks fine I guess.

@TristanCacqueray
Copy link
Contributor

One last error!

src/CLI.hs:32:41: error:
    Module ‘Options.Applicative.Help.Pretty’ does not export ‘string’
   |
32 | import Options.Applicative.Help.Pretty (string)
   |                                         ^^^^^^

morucci added 11 commits January 5, 2025 17:05
```
src/Json/Extras.hs:8:3-18: error: [GHC-69158]
    Conflicting exports for ‘toText’:
       ‘TextShort.toText’ exports ‘TextShort.toText’
         imported qualified from ‘Data.Text.Short’ at src/Json/Extras.hs:21:1-45
         (and originally defined in ‘text-short-0.1.6:Data.Text.Short.Internal’)
       ‘module Json’ exports ‘Json.toText’
         imported from ‘Json’ at src/Json/Extras.hs:26:1-25
  |
8 |   TextShort.toText,
  |   ^^^^^^^^^^^^^^^^
```
@TristanCacqueray
Copy link
Contributor

It looks like the hash function changed, you'll have to update the expected value in the test.

@TristanCacqueray
Copy link
Contributor

TristanCacqueray commented Jan 5, 2025

For fourmolu, here is some elisp for you:

(use-package haskell-mode
  :config
  ;; ensure run-haskell uses the simplest ghci subprocess
  (setq-default haskell-process-type 'auto)
  (add-hook 'haskell-mode-hook 'haskell-auto-insert-module-template)
  ;; auto format with fourmolu by default
  (reformatter-define fourmolu-format
    :program "fourmolu"
    :args `("--stdin-input-file" ,buffer-file-name))
  (add-hook 'haskell-mode-hook 'fourmolu-format-on-save-mode))

Thanks calling fourmolu-format-buffer I see the buffer to be formatted. However C-x C-s does not trigger fourmolu. Does that work for you ?

@TristanCacqueray
Copy link
Contributor

well done! Glad to see hspkgs is out of the equation 🥳

@TristanCacqueray TristanCacqueray added the merge me Trigger the merge process label Jan 5, 2025
@mergify mergify bot merged commit c102bb6 into change-metrics:master Jan 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants