diff --git a/cabal.project b/cabal.project index 1d5cbc535..6251cb149 100644 --- a/cabal.project +++ b/cabal.project @@ -1,4 +1,4 @@ -index-state: 2022-05-15T00:00:00Z +index-state: 2022-06-02T00:00:00Z packages: primer @@ -12,3 +12,14 @@ package * package primer test-options: "--size-cutoff=32768" + +-- https://github.com/protolude/protolude/issues/127 +allow-newer: + protolude:* + +-- https://github.com/protolude/protolude/issues/127 +source-repository-package + type: git + location: https://github.com/protolude/protolude + tag: 3e249724fd0ead27370c8c297b1ecd38f92cbd5b + --sha256: sha256-JyHAQfTTUswP8MeGEZibx/2/v01Q7cU5mNpnmDazh24= diff --git a/flake.lock b/flake.lock index ed523786d..70320fb74 100644 --- a/flake.lock +++ b/flake.lock @@ -89,11 +89,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1652416036, - "narHash": "sha256-cfNmuHmGwdhHB9/BT1dDxo5anYFAewuvZ/wVFDAgl8w=", + "lastModified": 1653679857, + "narHash": "sha256-9gn+1Xaqm2Mdc6QD+wHB74tJzn/+tqOSHzwz0C1212U=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "9c90a10f7c5d4e99392090820460c1fa7486ae2c", + "rev": "3380f53d06f484a87c5dd0317bc081dbc9f5f13d", "type": "github" }, "original": { @@ -136,11 +136,11 @@ }, "flake-utils": { "locked": { - "lastModified": 1652557277, - "narHash": "sha256-jSes9DaIVMdmwBB78KkFUVrlDzawmD62vrUg0GS2500=", + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "12806d31a381e7cd169a6bac35590e7b36dc5fe5", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", "type": "github" }, "original": { @@ -151,11 +151,11 @@ }, "flake-utils_2": { "locked": { - "lastModified": 1652372896, - "narHash": "sha256-lURGussfF3mGrFPQT3zgW7+RC0pBhbHzco0C7I+ilow=", + "lastModified": 1652776076, + "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", "owner": "numtide", "repo": "flake-utils", - "rev": "0d347c56f6f41de822a4f4c7ff5072f3382db121", + "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", "type": "github" }, "original": { @@ -166,11 +166,11 @@ }, "flake-utils_3": { "locked": { - "lastModified": 1652372896, - "narHash": "sha256-lURGussfF3mGrFPQT3zgW7+RC0pBhbHzco0C7I+ilow=", + "lastModified": 1652776076, + "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", "owner": "numtide", "repo": "flake-utils", - "rev": "0d347c56f6f41de822a4f4c7ff5072f3382db121", + "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", "type": "github" }, "original": { @@ -230,11 +230,11 @@ "hackage": { "flake": false, "locked": { - "lastModified": 1652577195, - "narHash": "sha256-BpjiUhjS1k3qWmGrMqhh/kPit8PEpLGFMAsQzGuAA1Q=", + "lastModified": 1654132593, + "narHash": "sha256-4rlo5zJqN8ixYgOT8GZps2rteQBrbrbWG7hiHNlOmHs=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "b0eecedf42be238ab752cf9c2d3ee86d33aa9d4c", + "rev": "b56ea8605eae78ce3c4a7ac58c532f384381ba28", "type": "github" }, "original": { @@ -254,11 +254,11 @@ "sops-nix": "sops-nix" }, "locked": { - "lastModified": 1652634427, - "narHash": "sha256-/mbgpgrm5PxRUMHDDTq+ZEJlAKSrfCl5Ivh/AuSY2Ho=", + "lastModified": 1653743514, + "narHash": "sha256-5zXca5ai0LPbkhLEHBTFg5UqO+U2kW25Fdv0TS+w8rA=", "owner": "hackworthltd", "repo": "hacknix", - "rev": "cfd4b373de29ff7e8857ceda9c5e30d3afc7dd8f", + "rev": "1501fefa9b1d3ddbcf172924e4188bf5f2e0f74f", "type": "github" }, "original": { @@ -267,6 +267,22 @@ "type": "github" } }, + "haskell-language-server": { + "flake": false, + "locked": { + "lastModified": 1654120290, + "narHash": "sha256-6NuFBnEzJPvWfvbYxXk/WCQDjsEbjCQ1nAelhBDi4yQ=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "140f9040ae88352ca1140a750e7c26485fdfbe17", + "type": "github" + }, + "original": { + "owner": "haskell", + "repo": "haskell-language-server", + "type": "github" + } + }, "haskell-nix": { "inputs": { "HTTP": "HTTP", @@ -292,11 +308,11 @@ "stackage": "stackage" }, "locked": { - "lastModified": 1652577389, - "narHash": "sha256-UQM12aLFi5eRL7lD0Ei1YnrmGMye4YPNhgtSBqIVd1E=", + "lastModified": 1654157487, + "narHash": "sha256-p/EA58HNSj8WFFORLrUOZO/2p1IoPYcPQojG79aFJYg=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "6d6df8044e390d9ec1eef61c38d72f55b6ad0548", + "rev": "91036142efe815a5d797e2b7eeb58caeb97a039d", "type": "github" }, "original": { @@ -363,7 +379,7 @@ "nix": { "inputs": { "lowdown-src": "lowdown-src", - "nixpkgs": "nixpkgs_5", + "nixpkgs": "nixpkgs_4", "nixpkgs-regression": "nixpkgs-regression" }, "locked": { @@ -418,11 +434,12 @@ }, "nixpkgs": { "locked": { - "lastModified": 1651804312, - "narHash": "sha256-DJxOGlxwQccuuwXUS0oRRkcNJbW5UP4fpsL5ga9ZwYw=", - "path": "/nix/store/0kdxl7yy21k1rzlvax8qbyf477ar750y-source", - "rev": "d59dd43e49f24b58fe8d5ded38cbdf00c3da4dc2", - "type": "path" + "lastModified": 1653326962, + "narHash": "sha256-W8feCYqKTsMre4nAEpv5Kx1PVFC+hao/LwqtB2Wci/8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "41cc1d5d9584103be4108c1815c350e07c807036", + "type": "github" }, "original": { "id": "nixpkgs", @@ -477,6 +494,38 @@ "type": "github" } }, + "nixpkgs-21_11": { + "locked": { + "lastModified": 1653132211, + "narHash": "sha256-5ugEYisGqixwarfn3BJvuWDnO6gT/AoxlsA6jnG8Fv8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b5991e4971523a5fcc9413b9003b58e5c15aa7d8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-21.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-22_05": { + "locked": { + "lastModified": 1653460991, + "narHash": "sha256-8MgFe84UUKw5k5MybirNH0S+oSluN2cRQGt+ZkW+dxQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0c3bf3a5c3ab6be29138b88900c417660a284fbd", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-regression": { "locked": { "lastModified": 1643052045, @@ -524,11 +573,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1652252629, - "narHash": "sha256-SvT64apetqc8P5nYp1/fOZvUmHUPdPFUZbhSpKy+1aI=", + "lastModified": 1653326962, + "narHash": "sha256-W8feCYqKTsMre4nAEpv5Kx1PVFC+hao/LwqtB2Wci/8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d2fc6856824cb87742177eefc8dd534bdb6c3439", + "rev": "41cc1d5d9584103be4108c1815c350e07c807036", "type": "github" }, "original": { @@ -539,22 +588,6 @@ } }, "nixpkgs_4": { - "locked": { - "lastModified": 1652574577, - "narHash": "sha256-MoSWPtue4Wi9+kRDxUbLWEBCL8Bswaa8kVMh2JYpSJg=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "118ec238bfb788a34f1d53c4d95931fadfa70367", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_5": { "locked": { "lastModified": 1632864508, "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", @@ -596,11 +629,11 @@ ] }, "locked": { - "lastModified": 1649054408, - "narHash": "sha256-wz8AH7orqUE4Xog29WMTqOYBs0DMj2wFM8ulrTRVgz0=", + "lastModified": 1652714503, + "narHash": "sha256-qQKVEfDe5FqvGgkZtg5Pc491foeiDPIOeycHMqnPDps=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "e5e7b3b542e7f4f96967966a943d7e1c07558042", + "rev": "521a524771a8e93caddaa0ac1d67d03766a8b0b3", "type": "github" }, "original": { @@ -614,6 +647,7 @@ "flake-compat": "flake-compat", "flake-utils": "flake-utils", "hacknix": "hacknix", + "haskell-language-server": "haskell-language-server", "haskell-nix": "haskell-nix", "nixpkgs": [ "haskell-nix", @@ -624,14 +658,19 @@ }, "sops-nix": { "inputs": { - "nixpkgs": "nixpkgs_4" + "nixpkgs": [ + "hacknix", + "nixpkgs" + ], + "nixpkgs-21_11": "nixpkgs-21_11", + "nixpkgs-22_05": "nixpkgs-22_05" }, "locked": { - "lastModified": 1649756291, - "narHash": "sha256-KTll8bCINAzIUGaaMrbn9wb5nfhkXRLgmFrWGR/Dku0=", + "lastModified": 1653462763, + "narHash": "sha256-n0beO7WNvAeEtTtnetzQCaGs615tU/DfM97k8r/7bUw=", "owner": "Mic92", "repo": "sops-nix", - "rev": "c2614c4fe61943b3d280ac1892fcebe6e8eaf8c8", + "rev": "7385b12722ce903e477878147794bed9040227e2", "type": "github" }, "original": { @@ -643,11 +682,11 @@ "stackage": { "flake": false, "locked": { - "lastModified": 1652577319, - "narHash": "sha256-zZxCo7vIdyjZueJD3VoR7YImsS54dRhqqVRcsLqUBP0=", + "lastModified": 1654046327, + "narHash": "sha256-IxX46Dh4OZpF3k7KPMa3tZSScYYGqFxXpCnMc0QRkuQ=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "49dfbc9cbf38cbf8180a432fcd6d390326c74fba", + "rev": "cc1d778723fcd431f9b2ed632a50c610c3e38b54", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 0bfdd93cf..75b77f097 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,10 @@ pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs"; # Fixes aarch64-darwin support. pre-commit-hooks-nix.inputs.flake-utils.follows = "flake-utils"; + + # Temporary workaround for HLS issues until the next release. + haskell-language-server.url = github:haskell/haskell-language-server; + haskell-language-server.flake = false; }; outputs = @@ -27,6 +31,7 @@ , hacknix , flake-utils , pre-commit-hooks-nix + , haskell-language-server , ... }@inputs: let @@ -47,11 +52,25 @@ in builtins.trace "Nix Primer version is ${v}" v; - ghcVersion = "ghc8107"; + # Workaround for https://github.com/input-output-hk/haskell.nix/issues/1177. + exceptionsWorkaround = version: { + inherit version; + modules = [ + ({ lib, ... }: { + reinstallableLibGhc = true; + }) + ]; + }; + + ghcVersion = "ghc923"; # We must keep the weeder version in sync with the version of # GHC we're using. - weederVersion = "2.2.0"; + weederVersion = "2.4.0"; + + # Fourmolu updates often formatting arbitrarily, and we want to + # have more control over this. + fourmoluVersion = "0.6.0.0"; forAllSupportedSystems = flake-utils.lib.eachSystem [ "x86_64-linux" @@ -66,6 +85,11 @@ haskell-nix.overlay (final: prev: let + ghc8107Tools = final.haskell-nix.tools "ghc8107" { + cabal-fmt = "latest"; + cabal-edit = "latest"; + }; + postgres-dev-password = "primer-dev"; postgres-dev-base-url = "postgres://postgres:${postgres-dev-password}@localhost:5432"; postgres-dev-primer-url = "${postgres-dev-base-url}/primer"; @@ -80,10 +104,59 @@ sqitchDir = ./sqitch; }); + # Temporary workaround for HLS issues until the next release. + hls = final.haskell-nix.cabalProject' { + compiler-nix-name = ghcVersion; + src = haskell-language-server; + sha256map."https://github.com/pepeiborra/ekg-json"."7a0af7a8fd38045fd15fb13445bdcc7085325460" = "fVwKxGgM0S4Kv/4egVAAiAjV7QB5PBqMVMCfsv7otIQ="; + }; + primer = final.haskell-nix.cabalProject { compiler-nix-name = ghcVersion; src = ./.; modules = [ + # https://github.com/input-output-hk/haskell.nix/issues/1177 + { + nonReinstallablePkgs = [ + "rts" + "ghc-heap" + "ghc-prim" + "integer-gmp" + "integer-simple" + "base" + "deepseq" + "array" + "ghc-boot-th" + "pretty" + "template-haskell" + "ghc-bignum" + "exceptions" + "stm" + "ghc-boot" + "ghc" + "Cabal" + "Win32" + "array" + "binary" + "bytestring" + "containers" + "directory" + "filepath" + "ghc-boot" + "ghc-compact" + "ghc-prim" + "hpc" + "mtl" + "parsec" + "process" + "text" + "time" + "transformers" + "unix" + "xhtml" + "terminfo" + ]; + } { # We want -Werror for Nix builds (primarily for CI). packages = @@ -164,25 +237,22 @@ tools = { ghcid = "latest"; - haskell-language-server = "latest"; + + # Temporary workaround for HLS issues until the next release. + #haskell-language-server = "latest"; + cabal = "latest"; - hlint = "latest"; - - # https://github.com/input-output-hk/haskell.nix/issues/1337 - fourmolu = { - version = "latest"; - modules = [ - ({ lib, ... }: { - options.nonReinstallablePkgs = lib.mkOption { apply = lib.remove "Cabal"; }; - }) - ]; - }; - - cabal-edit = "latest"; - cabal-fmt = "latest"; + hlint = exceptionsWorkaround "latest"; + weeder = exceptionsWorkaround weederVersion; + + fourmolu = fourmoluVersion; + + # Not yet working with GHC 9.2.2. + #cabal-edit = "latest"; + #cabal-fmt = "latest"; + #TODO Explicitly requiring tasty-discover shouldn't be necessary - see the commented-out `build-tool-depends` in primer.cabal. tasty-discover = "latest"; - weeder = weederVersion; }; buildInputs = (with final; [ @@ -214,6 +284,12 @@ delete-local-db dump-local-db restore-local-db + + ghc8107Tools.cabal-edit + ghc8107Tools.cabal-fmt + + # Temporary workaround for HLS issues until the next release. + hls.hsPkgs.haskell-language-server.components.exes.haskell-language-server ]); shellHook = '' @@ -277,6 +353,8 @@ inherit primer-openapi-spec; inherit run-primer; + + inherit (ghc8107Tools) cabal-edit cabal-fmt; } ) ]; @@ -304,7 +382,7 @@ weeder = let - weederTool = pkgs.haskell-nix.tool ghcVersion "weeder" weederVersion; + weederTool = pkgs.haskell-nix.tool ghcVersion "weeder" (exceptionsWorkaround weederVersion); getLibHIE = package: pkgs.lib.optional (package.components ? library) { name = "${package.identifier.name}-library"; path = package.components.library.hie; }; @@ -346,18 +424,11 @@ # Override the default nix-pre-commit-hooks tools with the version # we're using. haskellNixTools = pkgs.haskell-nix.tools ghcVersion { - hlint = "latest"; - cabal-fmt = "latest"; + hlint = exceptionsWorkaround "latest"; + fourmolu = fourmoluVersion; - # https://github.com/input-output-hk/haskell.nix/issues/1337 - fourmolu = { - version = "latest"; - modules = [ - ({ lib, ... }: { - options.nonReinstallablePkgs = lib.mkOption { apply = lib.remove "Cabal"; }; - }) - ]; - }; + # Not yet working with GHC 9.2.2. + #cabal-fmt = "latest"; }; in pre-commit-hooks-nix.lib.${system}.run { @@ -373,6 +444,7 @@ # we're using. tools = { inherit (pkgs) nixpkgs-fmt; + inherit (pkgs) cabal-fmt; } // haskellNixTools; excludes = [ diff --git a/primer-service/exe-server/Main.hs b/primer-service/exe-server/Main.hs index ada675182..cb70c7698 100644 --- a/primer-service/exe-server/Main.hs +++ b/primer-service/exe-server/Main.hs @@ -4,7 +4,6 @@ module Main (main) where import Foreword hiding ( catchJust, - option, ) import Control.Concurrent.STM ( diff --git a/primer-service/primer-service.cabal b/primer-service/primer-service.cabal index b18ce69e5..05acb9988 100644 --- a/primer-service/primer-service.cabal +++ b/primer-service/primer-service.cabal @@ -55,7 +55,7 @@ library , stm-containers >=1.1 && <=1.3 , streaming-commons ^>=0.2.2.4 , text >=1.2.3.2 && <=1.3 - , transformers >=0.5.6.2 && <=0.6 + , transformers >=0.5.6.2 && <=0.7 , uuid ^>=1.3 , wai ^>=3.2 , wai-app-static ^>=3.1 diff --git a/primer/primer.cabal b/primer/primer.cabal index 9c447ca72..98620e402 100644 --- a/primer/primer.cabal +++ b/primer/primer.cabal @@ -158,7 +158,7 @@ test-suite primer-test , hedgehog-classes ^>=0.2.5.3 , hspec ^>=2.9.4 , hspec-megaparsec ^>=2.2.0 - , mmorph ^>=1.1.5 + , mmorph ^>=1.2.0 , mtl , optics , pretty-simple ^>=4.0.0 diff --git a/primer/src/Control/Monad/NestedError.hs b/primer/src/Control/Monad/NestedError.hs index 9c4cf74f7..7290dd3c4 100644 --- a/primer/src/Control/Monad/NestedError.hs +++ b/primer/src/Control/Monad/NestedError.hs @@ -59,7 +59,7 @@ class (Monad m, MonadError larger m) => MonadNestedError smaller larger m | m -> catchError' :: m a -> (smaller -> m a) -> m a -- | We can trivially lift the type to itself -instance (Monad m, MonadError e m) => MonadNestedError e e m where +instance (MonadError e m) => MonadNestedError e e m where throwError' = throwError catchError' = catchError @@ -67,7 +67,7 @@ instance (Monad m, MonadError e m) => MonadNestedError e e m where -- instance for it. instance {-# OVERLAPPABLE #-} - (Monad m, MonadError larger m, AsType smaller larger) => + (MonadError larger m, AsType smaller larger) => MonadNestedError smaller larger m where throwError' = throwError . injectTyped