From b05c2b516cf586b2477ee1825b29c5cdbca59dff Mon Sep 17 00:00:00 2001 From: Ben Orchard Date: Sun, 15 Sep 2024 17:22:33 +0100 Subject: [PATCH 1/2] try to permit building with GHC 9.6 --- flake.lock | 36 ++++++++++++++------------------ flake.nix | 46 ++++++++++++++++++++++++++++++++++++----- fortran-src.cabal | 20 +++++++++--------- haskell-flake-ghc92.nix | 30 +++++++++++++++++++++++++++ haskell-flake-ghc94.nix | 30 +++++++++++++++++++++++++++ package.yaml | 9 ++++---- 6 files changed, 131 insertions(+), 40 deletions(-) create mode 100644 haskell-flake-ghc92.nix create mode 100644 haskell-flake-ghc94.nix diff --git a/flake.lock b/flake.lock index 8c181208..bb7eacf3 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1685662779, - "narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=", + "lastModified": 1726153070, + "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3", + "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "haskell-flake": { "locked": { - "lastModified": 1687375904, - "narHash": "sha256-cBLffqOaf77zj+d/zYL27ti4MX7mOCTMrJrue7l5Muk=", + "lastModified": 1725811060, + "narHash": "sha256-lmPoWYNT8kI8LSTa0Z3id38SoR05+05IEZ3fxeIwOzE=", "owner": "srid", "repo": "haskell-flake", - "rev": "ab43c9d07efeaaeafd89c0ba371651340b52147d", + "rev": "9b490fe01ec8f6858f43d3cc81bfbbd0000eb29e", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1687488839, - "narHash": "sha256-7JDjuyHwUvGJJge9jxfRJkuYyL5G5yipspc4J3HwjGA=", + "lastModified": 1726042813, + "narHash": "sha256-LnNKCCxnwgF+575y0pxUdlGZBO/ru1CtGHIqQVfvjlA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f9e94676ce6c7531c44d38da61d2669ebec0f603", + "rev": "159be5db480d1df880a0135ca0bfed84c2f88353", "type": "github" }, "original": { @@ -51,20 +51,14 @@ }, "nixpkgs-lib": { "locked": { - "dir": "lib", - "lastModified": 1685564631, - "narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a", - "type": "github" + "lastModified": 1725233747, + "narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" }, "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" } }, "root": { diff --git a/flake.nix b/flake.nix index db910f0e..d38c33e0 100644 --- a/flake.nix +++ b/flake.nix @@ -4,13 +4,49 @@ flake-parts.url = "github:hercules-ci/flake-parts"; haskell-flake.url = "github:srid/haskell-flake"; }; - outputs = inputs@{ self, nixpkgs, flake-parts, ... }: - flake-parts.lib.mkFlake { inherit inputs; } { - systems = nixpkgs.lib.systems.flakeExposed; + outputs = inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = inputs.nixpkgs.lib.systems.flakeExposed; imports = [ inputs.haskell-flake.flakeModule ]; perSystem = { self', pkgs, config, ... }: { - packages.default = self'.packages.fortran-src; - haskellProjects.default = {}; + packages.default = self'.packages.fortran-src-ghc92-fortran-src; + devShells.default = self'.devShells.fortran-src-ghc92; + + haskellProjects.ghc92 = import ./haskell-flake-ghc92.nix pkgs; + haskellProjects.fortran-src-ghc92 = { + basePackages = config.haskellProjects.ghc92.outputs.finalPackages; + devShell = { + tools = hp: { + # use nixpkgs cabal-install + cabal-install = pkgs.cabal-install; + + # disable these while unused (often slow/annoying to build) + haskell-language-server = null; + ghcid = null; + hlint = null; + }; + }; + }; + + haskellProjects.ghc94 = import ./haskell-flake-ghc94.nix pkgs; + haskellProjects.fortran-src-ghc94 = { + basePackages = config.haskellProjects.ghc94.outputs.finalPackages; + devShell = { + tools = hp: { + # use nixpkgs cabal-install + cabal-install = pkgs.cabal-install; + + # disable these while unused (often slow/annoying to build) + haskell-language-server = null; + ghcid = null; + hlint = null; + }; + }; + }; + + haskellProjects.ghc96 = { + basePackages = pkgs.haskell.packages.ghc96; + }; }; }; } diff --git a/fortran-src.cabal b/fortran-src.cabal index 60a118cb..eb23f0a3 100644 --- a/fortran-src.cabal +++ b/fortran-src.cabal @@ -1,6 +1,6 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.37.0. +-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack @@ -200,9 +200,9 @@ library , mtl >=2.2 && <3 , pretty >=1.1 && <2 , process >=1.2.0.0 - , singletons >=3.0 && <3.2 - , singletons-base >=3.0 && <3.2 - , singletons-th >=3.0 && <3.2 + , singletons ==3.0.* + , singletons-base >=3.0 && <3.3 + , singletons-th >=3.0 && <3.3 , temporary >=1.2 && <1.4 , text >=1.2 && <2.1 , uniplate >=1.6 && <2 @@ -264,9 +264,9 @@ executable fortran-src , mtl >=2.2 && <3 , pretty >=1.1 && <2 , process >=1.2.0.0 - , singletons >=3.0 && <3.2 - , singletons-base >=3.0 && <3.2 - , singletons-th >=3.0 && <3.2 + , singletons ==3.0.* + , singletons-base >=3.0 && <3.3 + , singletons-th >=3.0 && <3.3 , temporary >=1.2 && <1.4 , text >=1.2 && <2.1 , uniplate >=1.6 && <2 @@ -363,9 +363,9 @@ test-suite spec , mtl >=2.2 && <3 , pretty >=1.1 && <2 , process >=1.2.0.0 - , singletons >=3.0 && <3.2 - , singletons-base >=3.0 && <3.2 - , singletons-th >=3.0 && <3.2 + , singletons ==3.0.* + , singletons-base >=3.0 && <3.3 + , singletons-th >=3.0 && <3.3 , temporary >=1.2 && <1.4 , text >=1.2 && <2.1 , uniplate >=1.6 && <2 diff --git a/haskell-flake-ghc92.nix b/haskell-flake-ghc92.nix new file mode 100644 index 00000000..67443517 --- /dev/null +++ b/haskell-flake-ghc92.nix @@ -0,0 +1,30 @@ +pkgs: { + # disable local project options (always do this for package sets) + defaults.packages = {}; + devShell.enable = false; + autoWire = []; + + basePackages = pkgs.haskell.packages.ghc92; + packages = { + # GHC 9.2 libraries + singletons-th.source = "3.1"; + singletons-base.source = "3.1"; + singletons.source = "3.0.1"; # req because singletons-th-3.1 had bad bounds + th-desugar.source = "1.13.1"; + th-abstraction.source = "0.4.5.0"; + }; + + # (note this is actually unused/we have to duplicate because it doesn't get + # packed into basePackages or any key we can use... but nice to document here) + devShell = { + tools = hp: { + # by default, haskell-flake uses the Haskell packages versions of these + # tools (from hp). be warned, these can be a pain to build alternatively, + # you may use nixpkgs versions via pkgs + + # as of 2024-09-13 nixpkgs-unstable can't build cabal-install on GHC 9.2. + # no problem, use nixpkgs version (shouldn't really matter how built) + cabal-install = pkgs.cabal-install; + }; + }; +} diff --git a/haskell-flake-ghc94.nix b/haskell-flake-ghc94.nix new file mode 100644 index 00000000..6ebf68e8 --- /dev/null +++ b/haskell-flake-ghc94.nix @@ -0,0 +1,30 @@ +pkgs: { + # disable local project options (always do this for package sets) + defaults.packages = {}; + devShell.enable = false; + autoWire = []; + + basePackages = pkgs.haskell.packages.ghc94; + packages = { + # GHC 9.4 libraries + singletons-th.source = "3.1.1"; + singletons-base.source = "3.1.1"; + #singletons.source = "3.0.1"; + th-desugar.source = "1.14"; + th-abstraction.source = "0.4.5.0"; + }; + + # (note this is actually unused/we have to duplicate because it doesn't get + # packed into basePackages or any key we can use... but nice to document here) + devShell = { + tools = hp: { + # by default, haskell-flake uses the Haskell packages versions of these + # tools (from hp). be warned, these can be a pain to build alternatively, + # you may use nixpkgs versions via pkgs + + # as of 2024-09-13 nixpkgs-unstable can't build cabal-install on GHC 9.4. + # no problem, use nixpkgs version (shouldn't really matter how built) + cabal-install = pkgs.cabal-install; + }; + }; +} diff --git a/package.yaml b/package.yaml index 5f5f04b6..cc6e6624 100644 --- a/package.yaml +++ b/package.yaml @@ -99,10 +99,11 @@ dependencies: - either ^>=5.0.1.1 - process >= 1.2.0.0 -# 3.0 requires GHC 9.0; 3.1 requires GHC 9.2 -- singletons >= 3.0 && < 3.2 -- singletons-th >= 3.0 && < 3.2 -- singletons-base >= 3.0 && < 3.2 +- singletons >= 3.0 && < 3.1 + +# 3.0 = GHC 9.0, 3.1 = GHC 9.2, 3.1.1 = GHC 9.4, 3.2 = GHC 9.6 +- singletons-th >= 3.0 && < 3.3 +- singletons-base >= 3.0 && < 3.3 library: source-dirs: src From d85c5d682b86fa77790f7791891fc33cd45a50e6 Mon Sep 17 00:00:00 2001 From: Ben Orchard Date: Sun, 15 Sep 2024 17:35:47 +0100 Subject: [PATCH 2/2] tweak imports for GHC 9.6 --- src/Language/Fortran/Analysis/BBlocks.hs | 1 + src/Language/Fortran/Analysis/DataFlow.hs | 1 + src/Language/Fortran/Analysis/ModGraph.hs | 2 +- src/Language/Fortran/Analysis/Renaming.hs | 1 + src/Language/Fortran/Analysis/Types.hs | 1 + src/Language/Fortran/Parser.hs | 1 - src/Language/Fortran/Util/ModFile.hs | 1 + test/Language/Fortran/Parser/Free/Fortran95Spec.hs | 2 +- 8 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Language/Fortran/Analysis/BBlocks.hs b/src/Language/Fortran/Analysis/BBlocks.hs index 208e66d4..3eb7c495 100644 --- a/src/Language/Fortran/Analysis/BBlocks.hs +++ b/src/Language/Fortran/Analysis/BBlocks.hs @@ -13,6 +13,7 @@ import Data.List (unfoldr, foldl') import Control.Monad import Control.Monad.State.Lazy hiding (fix) import Control.Monad.Writer hiding (fix) +import Control.Monad ( forM_ ) -- required for mtl-2.3 (GHC 9.6) import Text.PrettyPrint.GenericPretty (pretty, Out) import Text.PrettyPrint (render) import Language.Fortran.Analysis diff --git a/src/Language/Fortran/Analysis/DataFlow.hs b/src/Language/Fortran/Analysis/DataFlow.hs index 19fa58d4..25b654d7 100644 --- a/src/Language/Fortran/Analysis/DataFlow.hs +++ b/src/Language/Fortran/Analysis/DataFlow.hs @@ -42,6 +42,7 @@ import Data.Graph.Inductive hiding (trc, dom, order, inn, out, rc) import Data.Maybe import Data.List (foldl', foldl1', (\\), union, intersect) import Control.Monad.Writer hiding (fix) +import Control.Monad -- required for mtl-2.3 (GHC 9.6) import qualified Language.Fortran.Repr as Repr import qualified Language.Fortran.Repr.Eval.Value as Repr diff --git a/src/Language/Fortran/Analysis/ModGraph.hs b/src/Language/Fortran/Analysis/ModGraph.hs index adb32ac8..fdbe02ae 100644 --- a/src/Language/Fortran/Analysis/ModGraph.hs +++ b/src/Language/Fortran/Analysis/ModGraph.hs @@ -10,8 +10,8 @@ import Language.Fortran.Util.ModFile import Language.Fortran.Util.Files import Prelude hiding (mod) -import Control.Monad import Control.Monad.State.Strict +import Control.Monad ( forM_ ) -- required for mtl-2.3 (GHC 9.6) import Data.Data import Data.Generics.Uniplate.Data import Data.Graph.Inductive hiding (version) diff --git a/src/Language/Fortran/Analysis/Renaming.hs b/src/Language/Fortran/Analysis/Renaming.hs index 79468deb..9cbb5293 100644 --- a/src/Language/Fortran/Analysis/Renaming.hs +++ b/src/Language/Fortran/Analysis/Renaming.hs @@ -20,6 +20,7 @@ import qualified Data.List as L import Data.Map (insert, empty, lookup, Map) import qualified Data.Map.Strict as M import Control.Monad.State.Strict +import Control.Monad -- required for mtl-2.3 (GHC 9.6) import Data.Generics.Uniplate.Data import Data.Data import Data.Functor.Identity (Identity) diff --git a/src/Language/Fortran/Analysis/Types.hs b/src/Language/Fortran/Analysis/Types.hs index d2b684ce..536255cb 100644 --- a/src/Language/Fortran/Analysis/Types.hs +++ b/src/Language/Fortran/Analysis/Types.hs @@ -23,6 +23,7 @@ import Data.Maybe (maybeToList) import Data.List (find, foldl') import Control.Monad.State.Strict import Control.Monad.Reader +import Control.Monad -- required for mtl-2.3 (GHC 9.6) import Data.Generics.Uniplate.Data import Data.Data import Language.Fortran.Analysis diff --git a/src/Language/Fortran/Parser.hs b/src/Language/Fortran/Parser.hs index 0df6bff4..5c2c0811 100644 --- a/src/Language/Fortran/Parser.hs +++ b/src/Language/Fortran/Parser.hs @@ -23,7 +23,6 @@ module Language.Fortran.Parser -- * Other parsers , f90Expr - , f77lIncludesNoTransform , byVerFromFilename -- ** Statement diff --git a/src/Language/Fortran/Util/ModFile.hs b/src/Language/Fortran/Util/ModFile.hs index 67297422..b7f73cfe 100644 --- a/src/Language/Fortran/Util/ModFile.hs +++ b/src/Language/Fortran/Util/ModFile.hs @@ -71,6 +71,7 @@ import qualified Language.Fortran.Util.Position as P import Language.Fortran.Util.Files ( getDirContents ) import Control.Monad.State +import Control.Monad -- required for mtl-2.3 (GHC 9.6) import Data.Binary (Binary, encode, decodeOrFail) import qualified Data.ByteString.Lazy.Char8 as LB import Data.Data diff --git a/test/Language/Fortran/Parser/Free/Fortran95Spec.hs b/test/Language/Fortran/Parser/Free/Fortran95Spec.hs index 20d3ec9f..d317b2e6 100644 --- a/test/Language/Fortran/Parser/Free/Fortran95Spec.hs +++ b/test/Language/Fortran/Parser/Free/Fortran95Spec.hs @@ -15,7 +15,7 @@ import qualified Language.Fortran.Parser.Free.Fortran95 as F95 import qualified Language.Fortran.Parser.Free.Lexer as Free import qualified Data.List as List -import Data.Foldable(forM_) +import Control.Monad ( forM_ ) import qualified Data.ByteString.Char8 as B import Control.Exception (evaluate)