From bfd179a9393b852e635f4b1b7ff9869416b6556e Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Wed, 15 May 2024 20:31:07 +0400 Subject: [PATCH 1/3] fix for GHC 9.10 - New stack builder for 9.8 - nixpkgs bump - Disabled the "buildFromSdist". I don't remember why this was there and looks like it adds some dependencies to the build. - Removed nix ghc 8.8 support, not in nixpkgs anymore. This is still tested by stack. - Added builder `pyf_910`, works when using `nix develop .#pyf_910`, but build is broken. - Fixed the CPP code for GHC 9.8. I wrongly tested for GHC 9.8 instead of GHC 9.10 in previous support commit for 9.10, resulting in broken 9.8. This is fixed and 9.8 was tested again. --- .github/workflows/master.yml | 4 ++- flake.lock | 13 ++++----- flake.nix | 51 +++++++++++++++++++++--------------- src/PyF/Internal/Meta.hs | 6 ++--- src/PyF/Internal/QQ.hs | 2 +- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 4bc1f91..5833013 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -31,8 +31,10 @@ jobs: run: sudo apt-get install haskell-stack # Build stack + - name: Stack 9.8 + run: stack --resolver nightly-2024-05-15 test - name: Stack 9.6 - run: stack --resolver nightly-2023-10-24 test + run: stack --resolver lts-22.22 test - name: Stack 9.4 run: stack --resolver lts-21.17 test - name: Stack 9.2 diff --git a/flake.lock b/flake.lock index eee7723..c67ca9b 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -20,15 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1698226488, - "narHash": "sha256-DdmQFlDZfRnXkW1VRa3J5bzmDgtRWZ9NU44fN66CbIA=", + "lastModified": 1715759831, + "narHash": "sha256-IqSVO1C30USnIVzDoRZdBNC7uYPuRbxBeaty32CU4p8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "be5c30bf2c89ccfd6e2d8ebba54c25d7c0c80764", + "rev": "54b7ab5b45c62a29e1c5a6dab12df27d857ce3d1", "type": "github" }, "original": { "owner": "nixos", + "ref": "haskell-updates", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 6368396..d30acc3 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "PyF"; inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.nixpkgs.url = "github:nixos/nixpkgs"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/haskell-updates"; # Broken: see https://github.com/NixOS/nix/issues/5621 #nixConfig.allow-import-from-derivation = true; @@ -45,7 +45,7 @@ ++ [ hPkgs.haskell-language-server ]; }); - pkg = (haskell.lib.buildFromSdist + pkg = ( (hPkgs.callCabal2nix "PyF" sources { })).overrideAttrs (oldAttrs: { buildInputs = oldAttrs.buildInputs; @@ -64,9 +64,7 @@ }); }); - pyf_88 = pyfBuilder (haskell.packages.ghc88.override { - overrides = self: super: with haskell.lib; { }; - }); + # GHC 8.8 is not in nixpkgs anymore. pyf_810 = pyfBuilder (haskell.packages.ghc810.override { overrides = self: super: with haskell.lib; { }; @@ -100,36 +98,47 @@ }; }); - pyf_98 = pyfBuilder ((haskell.packages.ghc98.override { + pyf_98 = pkgs.haskell.lib.dontCheck (pyfBuilder ((haskell.packages.ghc98.override { overrides = self: super: with haskell.lib; { # Bump hspec (and dependencies) - hspec-core = super.callHackage "hspec-core" "2.11.6" {}; - hspec-meta = super.callHackage "hspec-meta" "2.11.6" {}; - hspec = super.callHackage "hspec" "2.11.6" {}; - hspec-discover = super.callHackage "hspec-discover" "2.11.6" {}; - hspec-expectations = super.callHackage "hspec-expectations" "0.8.4" {}; - tagged = doJailbreak super.tagged; + #hspec-core = super.callHackage "hspec-core" "2.11.6" {}; + #hspec-meta = super.callHackage "hspec-meta" "2.11.6" {}; + #hspec = super.callHackage "hspec" "2.11.6" {}; + #hspec-discover = super.callHackage "hspec-discover" "2.11.6" {}; + #hspec-expectations = super.callHackage "hspec-expectations" "0.8.4" {}; + #tagged = doJailbreak super.tagged; - # Disabling tests breaks the loop with hspec - base-orphans = dontCheck super.base-orphans; - splitmix = doJailbreak super.splitmix; + ## Disabling tests breaks the loop with hspec + #base-orphans = dontCheck super.base-orphans; + #splitmix = doJailbreak super.splitmix; }; - })); + }))); + + pyf_910 = pyfBuilder (haskell.packages.ghc910.override { + overrides = self: super: with haskell.lib; rec { + primitive = dontCheck super.primitive_0_9_0_0; + HUnit = dontCheck super.HUnit; + call-stack = dontCheck super.call-stack; + hspec-expectations = dontCheck super.hspec-expectations; + QuickCheck = dontCheck super.QuickCheck; + hspec-discover = dontCheck super.hspec-discover; + }; + }); pyf_all = linkFarmFromDrvs "all_pyf" [ pyf_86 - pyf_88 pyf_810 pyf_90 pyf_92 pyf_94 pyf_96 - - # Nix build of the different component for testing in 98 are not working - # But building with cabal works - # pyf_98 + pyf_98 + + # https://github.com/NixOS/nixpkgs/pull/311912/files + # For some reason, nixpkgs does not build correctly with recent cabal + pyf_910 ]; # Only the current build is built with python3 support diff --git a/src/PyF/Internal/Meta.hs b/src/PyF/Internal/Meta.hs index dccd15e..53cbf12 100644 --- a/src/PyF/Internal/Meta.hs +++ b/src/PyF/Internal/Meta.hs @@ -161,7 +161,7 @@ toExp _ Expr.HsIPVar {} = noTH "toExp" "HsIPVar" toExp _ (Expr.HsLit _ l) = TH.LitE (toLit l) toExp _ (Expr.HsOverLit _ OverLit {ol_val}) = TH.LitE (toLit' ol_val) toExp d (Expr.HsApp _ e1 e2) = TH.AppE (toExp d . unLoc $ e1) (toExp d . unLoc $ e2) -#if MIN_VERSION_ghc(9,8,0) +#if MIN_VERSION_ghc(9,10,0) toExp d (Expr.HsAppType _ e HsWC{hswc_body}) = TH.AppTypeE (toExp d . unLoc $ e) (toType . unLoc $ hswc_body) toExp d (Expr.ExprWithTySig _ e HsWC{hswc_body=unLoc -> HsSig{sig_body}}) = TH.SigE (toExp d . unLoc $ e) (toType . unLoc $ sig_body) #elif MIN_VERSION_ghc(9,6,0) @@ -180,7 +180,7 @@ toExp d (Expr.ExprWithTySig HsWC{hswc_body=HsIB{hsib_body}} e) = TH.SigE (toExp toExp d (Expr.OpApp _ e1 o e2) = TH.UInfixE (toExp d . unLoc $ e1) (toExp d . unLoc $ o) (toExp d . unLoc $ e2) toExp d (Expr.NegApp _ e _) = TH.AppE (TH.VarE 'negate) (toExp d . unLoc $ e) -- NOTE: for lambda, there is only one match -#if MIN_VERSION_ghc(9,8,0) +#if MIN_VERSION_ghc(9,10,0) toExp d (Expr.HsLam _ _ (Expr.MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (Expr.GRHSs _ [unLoc -> Expr.GRHS _ _ (unLoc -> e)] _)])))) = TH.LamE (fmap (toPat d) ps) (toExp d e) #elif MIN_VERSION_ghc(9,6,0) toExp d (Expr.HsLam _ (Expr.MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (Expr.GRHSs _ [unLoc -> Expr.GRHS _ _ (unLoc -> e)] _)])))) = TH.LamE (fmap (toPat d) ps) (toExp d e) @@ -218,7 +218,7 @@ toExp d (Expr.ExplicitTuple _ (map unLoc -> args) boxity) = ctor tupArgs {- ORMOLU_ENABLE -} -- toExp (Expr.List _ xs) = TH.ListE (fmap toExp xs) -#if MIN_VERSION_ghc(9,8,0) +#if MIN_VERSION_ghc(9,10,0) toExp d (Expr.HsPar _ e) = TH.ParensE (toExp d . unLoc $ e) #elif MIN_VERSION_ghc(9,3,0) toExp d (Expr.HsPar _ _ e _) = TH.ParensE (toExp d . unLoc $ e) diff --git a/src/PyF/Internal/QQ.hs b/src/PyF/Internal/QQ.hs index 8d93f7a..76c6508 100644 --- a/src/PyF/Internal/QQ.hs +++ b/src/PyF/Internal/QQ.hs @@ -198,7 +198,7 @@ findFreeVariables item = allNames Just (HsVar _ l) -> [l] #endif -#if MIN_VERSION_ghc(9,8,0) +#if MIN_VERSION_ghc(9,10,0) Just (HsLam _ _ (MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (GRHSs _ [unLoc -> GRHS _ _ (unLoc -> e)] _)])))) -> filter keepVar subVars #elif MIN_VERSION_ghc(9,6,0) Just (HsLam _ (MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (GRHSs _ [unLoc -> GRHS _ _ (unLoc -> e)] _)])))) -> filter keepVar subVars From 3f10671c2cfaa276007f7a98584301aad46fb096 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Wed, 15 May 2024 21:00:42 +0400 Subject: [PATCH 2/3] github: workaround the disk space limitation Instead of running one job building ALL GHC version, we use a matrix of job. That's more duplication (compared to just follows what's in flake.nix), but should workaround the limitation. --- .github/workflows/master.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 5833013..33966ce 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -7,9 +7,14 @@ on: branches: [ main ] jobs: - nix_build: + nix_matrix: + strategy: + matrix: + # 88 is not in nixpkgs anymore + # 910 does not build yet for unknown reason + # We are not using nix build .#pyf_all because of github disk limitations + ghc: [86, 90, 92, 94, 96, 98] runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - uses: cachix/install-nix-action@v21 @@ -19,8 +24,8 @@ jobs: authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' # Builds cabal (nix) - - name: Build with all supported GHC - run: nix build .#pyf_all + - name: Build with GHC ${{ matrix.ghc }} + run: nix build .#pyf_${{ matrix.ghc }} stack_build: runs-on: ubuntu-latest From 8fb11a39e9f27aca407c5f4fb191a7bad7a40933 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Wed, 15 May 2024 21:17:38 +0400 Subject: [PATCH 3/3] Setup stack matrix for github action --- .github/workflows/master.yml | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 33966ce..497cb16 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -28,27 +28,23 @@ jobs: run: nix build .#pyf_${{ matrix.ghc }} stack_build: + strategy: + matrix: + resolver: [ lts-14.27 # 8.6 + , lts-16.31 # 8.8 + , lts-17.1 # 8.10 + , lts-19.1 # 9.0 + , lts-20.26 # 9.2 + , lts-21.17 # 9.4 + , lts-22.22 # 9.6 + , nightly-2024-05-15 # 9.8 nightly + ] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Setup Stack run: sudo apt-get install haskell-stack - - # Build stack - - name: Stack 9.8 - run: stack --resolver nightly-2024-05-15 test - - name: Stack 9.6 - run: stack --resolver lts-22.22 test - - name: Stack 9.4 - run: stack --resolver lts-21.17 test - - name: Stack 9.2 - run: stack --resolver lts-20.26 test - - name: Stack 9.0 - run: stack --resolver lts-19.1 test - - name: Stack 8.10 - run: stack --resolver lts-17.1 test - - name: Stack 8.8 - run: stack --resolver lts-16.31 test - - name: Stack 8.6 - run: stack --resolver lts-14.27 test + - name: Stack resolver ${{ matrix.resolver }} + run: stack --resolver ${{ matrix.resolver }} test