From 725ea644256c90a2a510a678b56cc064fd68302b Mon Sep 17 00:00:00 2001 From: John Carey Date: Sat, 18 Nov 2023 18:52:14 -0800 Subject: [PATCH 1/4] Support GHC 9.4 Also support various dependencies and upgrade nixpkgs. --- Setup.hs | 12 ++- flake.nix | 8 +- grpc-mqtt.cabal | 23 +++-- nix/overlays/grpc.nix | 10 +++ nix/overlays/haskell.nix | 38 +++++--- nix/packages/chell.nix | 15 ++++ nix/packages/ghc-events.nix | 18 ++++ nix/packages/grpc-haskell-core.nix | 4 +- nix/packages/grpc-haskell.nix | 4 +- nix/packages/grpc.nix | 106 +++++++++++++++++++++++ nix/packages/large-generics.nix | 24 ----- nix/packages/large-records.nix | 27 ------ nix/packages/net-mqtt.nix | 18 ++-- nix/packages/proto3-suite.nix | 19 ++-- nix/packages/proto3-wire.nix | 15 ++-- nix/packages/record-dot-preprocessor.nix | 9 +- nix/packages/word-compat.nix | 8 +- src/Network/GRPC/MQTT/Option.hs | 4 +- src/Network/GRPC/MQTT/Option/CLevel.hs | 8 +- test/Test.hs | 5 ++ test/Test/Proto/Service.hs | 6 +- 21 files changed, 254 insertions(+), 127 deletions(-) create mode 100644 nix/overlays/grpc.nix create mode 100644 nix/packages/chell.nix create mode 100644 nix/packages/ghc-events.nix create mode 100644 nix/packages/grpc.nix delete mode 100644 nix/packages/large-generics.nix delete mode 100644 nix/packages/large-records.nix diff --git a/Setup.hs b/Setup.hs index 5b65cb4..d897d66 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,5 +1,6 @@ -- See the comments for 'ppProto'. +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wall #-} import Distribution.Simple @@ -15,6 +16,10 @@ import Distribution.Types.ComponentLocalBuildInfo (ComponentLocalBuildInfo) import Distribution.Verbosity (Verbosity) import System.FilePath ((), normalise) +#if MIN_VERSION_Cabal(3,8,0) +import Distribution.Simple.PreProcess (unsorted) +#endif + main :: IO () main = defaultMainWithHooks customHooks @@ -47,6 +52,9 @@ ppProto :: ppProto _buildInfo localBuildInfo _componentLocalBuildInfo = PreProcessor { platformIndependent = True , runPreProcessor = genProto localBuildInfo +#if MIN_VERSION_Cabal(3,8,0) + , ppOrdering = unsorted +#endif } genProto :: @@ -54,11 +62,11 @@ genProto :: (FilePath, FilePath) -> (FilePath, FilePath) -> Verbosity -> - IO () + IO () genProto localBuildInfo (inBaseDir, inRelativeFile) (outBaseDir, outRelativeFile) verbosity = do let inFile = normalise (inBaseDir inRelativeFile) - outFile = normalise (outBaseDir outRelativeFile) + outFile = normalise (outBaseDir outRelativeFile) info verbosity $ "compiling " ++ show inFile ++ " to " ++ show outFile (cpfProg, _) <- requireProgram verbosity cpfProgram (withPrograms localBuildInfo) diff --git a/flake.nix b/flake.nix index 015dfca..1e16063 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/21.05"; + nixpkgs.url = "github:NixOS/nixpkgs/23.05"; flake-utils.url = "github:numtide/flake-utils"; gitignore = { url = "github:hercules-ci/gitignore.nix"; @@ -11,7 +11,9 @@ outputs = { self, nixpkgs, flake-utils, gitignore }: flake-utils.lib.eachSystem ["x86_64-linux" "x86_64-darwin"] (system: let - ghc = "ghc8104"; + ghc = "ghc8107"; + + grpcOverlay = import nix/overlays/grpc.nix { }; haskellOverlay = import nix/overlays/haskell.nix { inherit gitignore ghc; @@ -19,7 +21,7 @@ pkgs = import nixpkgs { inherit system; - overlays = [ haskellOverlay ]; + overlays = [ grpcOverlay haskellOverlay ]; }; in { packages.default = pkgs.haskell.packages.${ghc}.grpc-mqtt; diff --git a/grpc-mqtt.cabal b/grpc-mqtt.cabal index 55e7d08..9a1245e 100644 --- a/grpc-mqtt.cabal +++ b/grpc-mqtt.cabal @@ -42,14 +42,14 @@ common common DeriveFoldable DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable DerivingStrategies DerivingVia FlexibleContexts FlexibleInstances FunctionalDependencies GADTs ImportQualifiedPost InstanceSigs KindSignatures - LambdaCase MultiParamTypeClasses NamedFieldPuns NoImplicitPrelude - NumericUnderscores OverloadedStrings PatternSynonyms RankNTypes - ScopedTypeVariables StandaloneDeriving TupleSections TypeApplications + LambdaCase MultiParamTypeClasses NamedFieldPuns NoImplicitPrelude + NumericUnderscores OverloadedStrings PatternSynonyms RankNTypes + ScopedTypeVariables StandaloneDeriving TupleSections TypeApplications TypeFamilies TypeOperators build-depends: , async >= 2.2.3 && < 2.3 - , base >= 4.14 && < 4.15 + , base >= 4.14 && < 4.18 , bytestring >= 0.10.6.0 && < 0.12.0 , containers >= 0.5 && < 0.7 , deepseq == 1.4.* @@ -57,18 +57,18 @@ common common , grpc-haskell-core >= 0.5.0 && < 0.6 , mtl >= 2.2.2 && < 2.3 , net-mqtt >= 0.8.2 && < 0.9 - , proto3-suite >= 0.5.2 && < 0.7 + , proto3-suite >= 0.5.2 && < 0.8 , proto3-wire >= 1.2.2 && < 1.5 - , relude >= 0.7.0 && < 0.8 + , relude >= 0.7.0 && < 1.2 , stm >= 2.5.0 && < 2.6 - , text >= 0.2 && < 1.3 - , time >= 1.9.3 && < 1.10 + , text >= 0.2 && < 1.3 || == 2.* + , time >= 1.9.3 && < 1.13 , turtle < 1.6.0 || >= 1.6.1 && < 1.7.0 , vector >= 0.11 && < 0.13 library import: common - ghc-options: + ghc-options: -O2 -fregs-iterative @@ -127,12 +127,11 @@ library build-depends: , conduit-extra >= 1.3.5 && < 1.4 , connection >= 0.3.1 && < 0.4 - , ghc-prim >= 0.6.1 && < 0.7 , network-conduit-tls >= 1.3.2 && < 1.4 , nonce >= 1.0.7 && < 1.1 , pqueue >= 1.4.1.3 && < 1.6 , safe-exceptions >= 0.1.7 && < 0.2 - , template-haskell >= 2.16.0 && < 2.17 + , template-haskell >= 2.16.0 && < 2.20 , unliftio >= 0.2.15 && < 0.3 , unliftio-core >= 0.2.0 && < 0.3 , unordered-containers >= 0.2.13 && < 0.3 @@ -196,7 +195,7 @@ test-suite test , grpc-mqtt , hedgehog , tasty - , tasty-hedgehog < 1.1.0.0 + , tasty-hedgehog < 1.5.0.0 , tasty-hunit , tls , uuid diff --git a/nix/overlays/grpc.nix b/nix/overlays/grpc.nix new file mode 100644 index 0000000..e8039b7 --- /dev/null +++ b/nix/overlays/grpc.nix @@ -0,0 +1,10 @@ +{ }: + +final: prev: { + grpc = final.callPackage (import ../packages/grpc.nix) { + # grpc builds with c++14 so abseil must also be built that way + abseil-cpp = final.abseil-cpp_202111.override { + cxxStandard = "14"; + }; + }; +} diff --git a/nix/overlays/haskell.nix b/nix/overlays/haskell.nix index eba92d2..e63207e 100644 --- a/nix/overlays/haskell.nix +++ b/nix/overlays/haskell.nix @@ -5,13 +5,25 @@ final: prev: { packages = prev.haskell.packages // { "${ghc}" = prev.haskell.packages."${ghc}".override (old: { overrides = prev.lib.fold prev.lib.composeExtensions (old.overrides or (_: _: { })) [ - (hfinal: _: { - large-generics = hfinal.callPackage ../packages/large-generics.nix { }; - large-records = hfinal.callPackage ../packages/large-records.nix { }; + (hfinal: hprev: { + # Support text v2 if using GHC 9.4+; otherwise + # use an older version that works with GHC 8.10.7. + chell = + if builtins.compareVersions hfinal.ghc.version "9.4" < 0 + then hprev.chell + else final.haskell.lib.doJailbreak (hfinal.callPackage ../packages/chell.nix { }); + + # The tests in data-diverse do not build with GHC 9.4. + data-diverse = final.haskell.lib.dontCheck hprev.data-diverse; + + # Needed by threadscope-0.2.14.1. + ghc-events = hfinal.callPackage ../packages/ghc-events.nix { }; + + # Support GHC 9.4. record-dot-preprocessor = hfinal.callPackage ../packages/record-dot-preprocessor.nix { }; }) (hfinal: hprev: { - net-mqtt = final.haskell.lib.dontCheck (hfinal.callPackage ../packages/net-mqtt.nix { }); + net-mqtt = final.haskell.lib.dontCheck (hfinal.callPackage ../packages/net-mqtt.nix { }); }) (hfinal: hprev: { proto3-wire = final.haskell.lib.dontCheck (hfinal.callPackage ../packages/proto3-wire.nix { }); @@ -25,10 +37,12 @@ final: prev: { word-compat = final.haskell.lib.dontCheck (hfinal.callPackage ../packages/word-compat.nix { }); }) (hfinal: _: { - grpc-haskell = final.haskell.lib.dontCheck (hfinal.callPackage ../packages/grpc-haskell.nix { }); - grpc-haskell-core = final.haskell.lib.dontCheck (hfinal.callPackage ../packages/grpc-haskell-core.nix { - gpr = final.grpc; - }); + grpc-haskell = final.haskell.lib.doJailbreak + (final.haskell.lib.dontCheck (hfinal.callPackage ../packages/grpc-haskell.nix { })); + grpc-haskell-core = final.haskell.lib.doJailbreak + (final.haskell.lib.dontCheck (hfinal.callPackage ../packages/grpc-haskell-core.nix { + gpr = final.grpc; + })); }) (hfinal: _: { grpc-mqtt = (hfinal.callCabal2nix "grpc-mqtt" (gitignore.lib.gitignoreSource ../..) { }).overrideAttrs (old: { @@ -59,8 +73,12 @@ final: prev: { final.mosquitto hsPkgs.hp2pretty hsPkgs.proto3-suite - hsPkgs.threadscope - ]; + ] ++ ( + # threadscope does not yet support template-haskell-2.19, the version for ghc 9.4 + if builtins.compareVersions hsPkgs.ghc.version "9.4" < 0 + then [hsPkgs.threadscope] + else [] + ); packages = pkgs: [pkgs.grpc-mqtt]; }; diff --git a/nix/packages/chell.nix b/nix/packages/chell.nix new file mode 100644 index 0000000..be57ec6 --- /dev/null +++ b/nix/packages/chell.nix @@ -0,0 +1,15 @@ +{ mkDerivation, ansi-terminal, base, bytestring, lib, options +, patience, random, template-haskell, text, transformers +}: +mkDerivation { + pname = "chell"; + version = "0.5.0.2"; + sha256 = "bbbb035b800ee924e5d14f6598fc16512b5065773b1d57a8fe08f8626fe9c1c7"; + libraryHaskellDepends = [ + ansi-terminal base bytestring options patience random + template-haskell text transformers + ]; + homepage = "https://github.com/typeclasses/chell"; + description = "A simple and intuitive library for automated testing"; + license = lib.licenses.mit; +} diff --git a/nix/packages/ghc-events.nix b/nix/packages/ghc-events.nix new file mode 100644 index 0000000..c12d6a8 --- /dev/null +++ b/nix/packages/ghc-events.nix @@ -0,0 +1,18 @@ +{ mkDerivation, array, base, binary, bytestring, containers, lib +, text, vector +}: +mkDerivation { + pname = "ghc-events"; + version = "0.17.0.3"; + sha256 = "bb8cd1998227a77d8874c2982fbf8e9ef210d80f7ae9c9bf3f6d90cdbce8a054"; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + array base binary bytestring containers text vector + ]; + executableHaskellDepends = [ base containers ]; + testHaskellDepends = [ base ]; + description = "Library and tool for parsing .eventlog files from GHC"; + license = lib.licenses.bsd3; + mainProgram = "ghc-events"; +} diff --git a/nix/packages/grpc-haskell-core.nix b/nix/packages/grpc-haskell-core.nix index 68558e5..61cf8ef 100644 --- a/nix/packages/grpc-haskell-core.nix +++ b/nix/packages/grpc-haskell-core.nix @@ -8,8 +8,8 @@ mkDerivation { version = "0.5.0"; src = fetchgit { url = "https://github.com/awakesecurity/gRPC-haskell.git"; - sha256 = "17wjm9lbyzhm98g4g36v3jlnr00s5yzilrv90p12mqgn3ffhkg28"; - rev = "d20c20d63c170b5eaf5725f03f7b7060352af402"; + sha256 = "0jznxcgcg31blihr81q85q3xzssdy1vkg06my97w6hmrfpvrd8gx"; + rev = "2f30434fe3526b306dcdb0da78dadf84efa315fc"; fetchSubmodules = true; }; postUnpack = "sourceRoot+=/core; echo source root reset to $sourceRoot"; diff --git a/nix/packages/grpc-haskell.nix b/nix/packages/grpc-haskell.nix index a57a6ea..41e7480 100644 --- a/nix/packages/grpc-haskell.nix +++ b/nix/packages/grpc-haskell.nix @@ -9,8 +9,8 @@ mkDerivation { version = "0.3.0"; src = fetchgit { url = "https://github.com/awakesecurity/gRPC-haskell.git"; - sha256 = "17wjm9lbyzhm98g4g36v3jlnr00s5yzilrv90p12mqgn3ffhkg28"; - rev = "d20c20d63c170b5eaf5725f03f7b7060352af402"; + sha256 = "0jznxcgcg31blihr81q85q3xzssdy1vkg06my97w6hmrfpvrd8gx"; + rev = "2f30434fe3526b306dcdb0da78dadf84efa315fc"; fetchSubmodules = true; }; isLibrary = true; diff --git a/nix/packages/grpc.nix b/nix/packages/grpc.nix new file mode 100644 index 0000000..8540192 --- /dev/null +++ b/nix/packages/grpc.nix @@ -0,0 +1,106 @@ +{ lib +, stdenv +, fetchFromGitHub +, fetchpatch +, buildPackages +, cmake +, zlib +, c-ares +, pkg-config +, re2 +, openssl +, protobuf +, grpc +, abseil-cpp +, libnsl + +# tests +, python3 +}: + +stdenv.mkDerivation rec { + pname = "grpc"; + version = "1.46.3"; # N.B: if you change this, please update: + # pythonPackages.grpcio-tools + # pythonPackages.grpcio-status + + src = fetchFromGitHub { + owner = "grpc"; + repo = "grpc"; + rev = "v${version}"; + sha256 = "sha256-RiXtKlRtlbqwrSxI904dgSu3da0A6Fwk+/hWHIG7A5E="; + fetchSubmodules = true; + }; + + patches = [ + # Fix build on armv6l (https://github.com/grpc/grpc/pull/21341) + (fetchpatch { + url = "https://github.com/grpc/grpc/commit/2f4cf1d9265c8e10fb834f0794d0e4f3ec5ae10e.patch"; + sha256 = "0ams3jmgh9yzwmxcg4ifb34znamr7pb4qm0609kvil9xqvkqz963"; + }) + + # Revert gRPC C++ Mutex to be an alias of Abseil, because it breaks dependent packages + (fetchpatch { + url = "https://github.com/grpc/grpc/commit/931f91b745cd5b2864a0d1787815871d0bd844ae.patch"; + sha256 = "0vc93g2i4982ys4gzyaxdv9ni25yk10sxq3n7fkz8dypy8sylck7"; + revert = true; + }) + ]; + + nativeBuildInputs = [ cmake pkg-config ] + ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) grpc; + propagatedBuildInputs = [ c-ares re2 zlib abseil-cpp ]; + buildInputs = [ openssl protobuf ] + ++ lib.optionals stdenv.isLinux [ libnsl ]; + + cmakeFlags = [ + "-DgRPC_ZLIB_PROVIDER=package" + "-DgRPC_CARES_PROVIDER=package" + "-DgRPC_RE2_PROVIDER=package" + "-DgRPC_SSL_PROVIDER=package" + "-DgRPC_PROTOBUF_PROVIDER=package" + "-DgRPC_ABSL_PROVIDER=package" + "-DBUILD_SHARED_LIBS=ON" + "-DCMAKE_SKIP_BUILD_RPATH=OFF" + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-D_gRPC_PROTOBUF_PROTOC_EXECUTABLE=${buildPackages.protobuf}/bin/protoc" + ] ++ lib.optionals ((stdenv.hostPlatform.useLLVM or false) && lib.versionOlder stdenv.cc.cc.version "11.0") [ + # Needs to be compiled with -std=c++11 for clang < 11. Interestingly this is + # only an issue with the useLLVM stdenv, not the darwin stdenvā€¦ + # https://github.com/grpc/grpc/issues/26473#issuecomment-860885484 + "-DCMAKE_CXX_STANDARD=11" + ]; + + # CMake creates a build directory by default, this conflicts with the + # basel BUILD file on case-insensitive filesystems. + preConfigure = '' + rm -vf BUILD + ''; + + # When natively compiling, grpc_cpp_plugin is executed from the build directory, + # needing to load dynamic libraries from the build directory, so we set + # LD_LIBRARY_PATH to enable this. When cross compiling we need to avoid this, + # since it can cause the grpc_cpp_plugin executable from buildPackages to + # crash if build and host architecture are compatible (e. g. pkgsLLVM). + preBuild = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' + export LD_LIBRARY_PATH=$(pwd)''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH + ''; + + NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=unknown-warning-option" + + lib.optionalString stdenv.isAarch64 "-Wno-error=format-security"; + + enableParallelBuilds = true; + + passthru.tests = { + inherit (python3.pkgs) grpcio-status grpcio-tools; + }; + + meta = with lib; { + description = "The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)"; + license = licenses.asl20; + maintainers = with maintainers; [ lnl7 marsam ]; + homepage = "https://grpc.io/"; + platforms = platforms.all; + changelog = "https://github.com/grpc/grpc/releases/tag/v${version}"; + }; +} diff --git a/nix/packages/large-generics.nix b/nix/packages/large-generics.nix deleted file mode 100644 index 8cbb15e..0000000 --- a/nix/packages/large-generics.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ mkDerivation, aeson, base, deepseq, fetchgit, generic-deriving -, generics-sop, lib, microlens, mtl, primitive, QuickCheck -, sop-core, tasty, tasty-hunit, tasty-quickcheck -}: -mkDerivation { - pname = "large-generics"; - version = "0.2.0.0"; - src = fetchgit { - url = "https://github.com/well-typed/large-records"; - sha256 = "0rzssshn6jjdp2l0gx2k60wca17ha62gxq51xyd4rl3vgh2ql7n0"; - rev = "f13dd4514a247dca4a24a7668d702695748f8105"; - fetchSubmodules = true; - }; - postUnpack = "sourceRoot+=/large-generics; echo source root reset to $sourceRoot"; - libraryHaskellDepends = [ - aeson base deepseq generics-sop primitive sop-core - ]; - testHaskellDepends = [ - aeson base generic-deriving generics-sop microlens mtl QuickCheck - sop-core tasty tasty-hunit tasty-quickcheck - ]; - description = "Generic programming API for large-records and large-anon"; - license = lib.licenses.bsd3; -} \ No newline at end of file diff --git a/nix/packages/large-records.nix b/nix/packages/large-records.nix deleted file mode 100644 index 99732d1..0000000 --- a/nix/packages/large-records.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ mkDerivation, base, containers, fetchgit, generic-deriving, ghc -, large-generics, lib, mtl, newtype, primitive -, record-dot-preprocessor, record-hasfield, syb, tasty, tasty-hunit -, template-haskell, transformers -}: -mkDerivation { - pname = "large-records"; - version = "0.2.2.0"; - src = fetchgit { - url = "https://github.com/well-typed/large-records"; - sha256 = "0rzssshn6jjdp2l0gx2k60wca17ha62gxq51xyd4rl3vgh2ql7n0"; - rev = "f13dd4514a247dca4a24a7668d702695748f8105"; - fetchSubmodules = true; - }; - postUnpack = "sourceRoot+=/large-records; echo source root reset to $sourceRoot"; - libraryHaskellDepends = [ - base containers ghc large-generics mtl primitive record-hasfield - syb template-haskell transformers - ]; - testHaskellDepends = [ - base generic-deriving large-generics mtl newtype - record-dot-preprocessor record-hasfield tasty tasty-hunit - template-haskell transformers - ]; - description = "Efficient compilation for large records, linear in the size of the record"; - license = lib.licenses.bsd3; -} \ No newline at end of file diff --git a/nix/packages/net-mqtt.nix b/nix/packages/net-mqtt.nix index 17db940..6ae9f79 100644 --- a/nix/packages/net-mqtt.nix +++ b/nix/packages/net-mqtt.nix @@ -1,19 +1,13 @@ { mkDerivation, async, attoparsec, attoparsec-binary, base, binary , bytestring, checkers, conduit, conduit-extra, connection -, containers, deepseq, fetchgit, hpack, HUnit, lib -, network-conduit-tls, network-uri, optparse-applicative -, QuickCheck, stm, tasty, tasty-hunit, tasty-quickcheck, text -, websockets +, containers, deepseq, HUnit, lib, network-conduit-tls, network-uri +, optparse-applicative, QuickCheck, stm, tasty, tasty-hunit +, tasty-quickcheck, text, websockets }: mkDerivation { pname = "net-mqtt"; - version = "0.8.2.2"; - src = fetchgit { - url = "https://github.com/dustin/mqtt-hs"; - sha256 = "0k57pl6vpnp8966bpng87jj80yqkdfy07z5f8x02y1x3dyvi3373"; - rev = "64c814c36d6a25e3d982873fd4e6fb64e643278b"; - fetchSubmodules = true; - }; + version = "0.8.2.5"; + sha256 = "3d41045cbc9b1adbaccab90ee9a4bc3e751fb41d50ea2fa65f7024231f7cde4c"; isLibrary = true; isExecutable = true; libraryHaskellDepends = [ @@ -21,7 +15,6 @@ mkDerivation { conduit-extra connection containers deepseq network-conduit-tls network-uri QuickCheck stm text websockets ]; - libraryToolDepends = [ hpack ]; executableHaskellDepends = [ async attoparsec attoparsec-binary base binary bytestring conduit conduit-extra connection containers deepseq network-conduit-tls @@ -33,7 +26,6 @@ mkDerivation { network-conduit-tls network-uri QuickCheck stm tasty tasty-hunit tasty-quickcheck text websockets ]; - prePatch = "hpack"; homepage = "https://github.com/dustin/mqtt-hs#readme"; description = "An MQTT Protocol Implementation"; license = lib.licenses.bsd3; diff --git a/nix/packages/proto3-suite.nix b/nix/packages/proto3-suite.nix index e39470f..c84c313 100644 --- a/nix/packages/proto3-suite.nix +++ b/nix/packages/proto3-suite.nix @@ -6,17 +6,17 @@ , lib, mtl, neat-interpolation, optparse-applicative , optparse-generic, parsec, parsers, pretty, pretty-show , proto3-wire, QuickCheck, quickcheck-instances, range-set-list -, safe, split, swagger2, system-filepath, tasty, tasty-hedgehog -, tasty-hunit, tasty-quickcheck, text, text-short, time -, transformers, turtle, vector +, record-hasfield, safe, split, swagger2, system-filepath, tasty +, tasty-hedgehog, tasty-hunit, tasty-quickcheck, text, text-short +, time, transformers, turtle, vector }: mkDerivation { pname = "proto3-suite"; - version = "0.6.0"; + version = "0.7.0"; src = fetchgit { - url = "https://github.com/awakesecurity/proto3-suite"; - sha256 = "1csl3yqz4yp3pi4vnijbfzd68yqamyky51fxgrc9k3304ssmzb42"; - rev = "b0a3308d9d1b1b070c371f90de984ff192020537"; + url = "https://github.com/awakesecurity/proto3-suite.git"; + sha256 = "16x6acbcd4sqscjqdwmp0j6rlfn7lczp3vsyqv6v8r8zxwm244dk"; + rev = "30599c127cc53838576992a33c8c9d91fd57b429"; fetchSubmodules = true; }; isLibrary = true; @@ -39,8 +39,9 @@ mkDerivation { aeson attoparsec base base64-bytestring bytestring cereal containers deepseq doctest generic-arbitrary hedgehog large-generics large-records mtl parsec pretty pretty-show - proto3-wire QuickCheck swagger2 tasty tasty-hedgehog tasty-hunit - tasty-quickcheck text text-short transformers turtle vector + proto3-wire QuickCheck record-hasfield swagger2 tasty + tasty-hedgehog tasty-hunit tasty-quickcheck text text-short + transformers turtle vector ]; description = "A higher-level API to the proto3-wire library"; license = lib.licenses.asl20; diff --git a/nix/packages/proto3-wire.nix b/nix/packages/proto3-wire.nix index 43ee634..0be4dca 100644 --- a/nix/packages/proto3-wire.nix +++ b/nix/packages/proto3-wire.nix @@ -1,5 +1,5 @@ { mkDerivation, base, bytestring, cereal, containers, criterion -, deepseq, doctest, ghc-prim, hashable, lib, parameterized +, deepseq, doctest, fetchgit, hashable, lib, parameterized , primitive, QuickCheck, random, safe, tasty, tasty-hunit , tasty-quickcheck, template-haskell, text, text-short , transformers, unordered-containers, vector, word-compat @@ -7,11 +7,16 @@ mkDerivation { pname = "proto3-wire"; version = "1.4.1"; - sha256 = "c5108b8d792b9327903b0086c5ef19bf16266e8b803b9b4e5320f8d42d163e52"; + src = fetchgit { + url = "https://github.com/awakesecurity/proto3-wire.git"; + sha256 = "1mq5qp778g5zjj17lj9d0db7b7j6bhv94lf68xlla5dba8vzfl8r"; + rev = "938523213d5de2d0ad9ece051d1a03002ee539cc"; + fetchSubmodules = true; + }; libraryHaskellDepends = [ - base bytestring cereal containers deepseq ghc-prim hashable - parameterized primitive QuickCheck safe template-haskell text - text-short transformers unordered-containers vector word-compat + base bytestring cereal containers deepseq hashable parameterized + primitive QuickCheck safe template-haskell text text-short + transformers unordered-containers vector word-compat ]; testHaskellDepends = [ base bytestring cereal doctest QuickCheck tasty tasty-hunit diff --git a/nix/packages/record-dot-preprocessor.nix b/nix/packages/record-dot-preprocessor.nix index d42e89f..6b1758c 100644 --- a/nix/packages/record-dot-preprocessor.nix +++ b/nix/packages/record-dot-preprocessor.nix @@ -3,10 +3,8 @@ }: mkDerivation { pname = "record-dot-preprocessor"; - version = "0.2.14"; - sha256 = "9788c5b21a6f981141924a2a9c148738b08c2b64dc0430b124e182312f48181e"; - revision = "1"; - editedCabalFile = "03sp3wkvl1x68pcjdrkxf4ys73x4ka4sz7x75icy4xd285zrzqb0"; + version = "0.2.16"; + sha256 = "2c067163a6308a61e65f88e168558ac5062e41b86cad9346898bdd77e72b1a80"; isLibrary = true; isExecutable = true; libraryHaskellDepends = [ base extra ghc uniplate ]; @@ -15,4 +13,5 @@ mkDerivation { homepage = "https://github.com/ndmitchell/record-dot-preprocessor#readme"; description = "Preprocessor to allow record.field syntax"; license = lib.licenses.bsd3; -} \ No newline at end of file + mainProgram = "record-dot-preprocessor"; +} diff --git a/nix/packages/word-compat.nix b/nix/packages/word-compat.nix index d968f45..da64f55 100644 --- a/nix/packages/word-compat.nix +++ b/nix/packages/word-compat.nix @@ -1,10 +1,10 @@ { mkDerivation, base, ghc-prim, lib }: - mkDerivation { pname = "word-compat"; - version = "0.0.2"; - sha256 = "36e5a1a17f20935f55bf274fb52cbb028d301fd48d814f574d3171ccc6bc9f98"; + version = "0.0.6"; + sha256 = "305c2a9f9aab68cd5a8c9babaa9bc845d296ec5697b7e4ac4a2b368243fb278a"; libraryHaskellDepends = [ base ghc-prim ]; + testHaskellDepends = [ base ]; description = "Compatibility shim for the Int/Word internal change in GHC 9.2"; license = lib.licenses.bsd3; -} \ No newline at end of file +} diff --git a/src/Network/GRPC/MQTT/Option.hs b/src/Network/GRPC/MQTT/Option.hs index eaee9d7..e18ccbc 100644 --- a/src/Network/GRPC/MQTT/Option.hs +++ b/src/Network/GRPC/MQTT/Option.hs @@ -56,7 +56,7 @@ where import Data.Data (Data) import Data.List qualified as List -import GHC.Prim (Proxy#, proxy#) +import GHC.Exts (Proxy#, proxy#) import Language.Haskell.TH.Syntax (Lift) @@ -193,7 +193,7 @@ wireEncodeProtoOptions' = toStrict . wireEncodeProtoOptions wireBuildProtoOptions :: FieldNumber -> ProtoOptions -> MessageBuilder wireBuildProtoOptions n ProtoOptions{..} = let varints :: [Word64] - varints = + varints = [ fromIntegral (fromEnum rpcBatchStream) , maybe 0 fromCLevel rpcServerCLevel , maybe 0 fromCLevel rpcClientCLevel diff --git a/src/Network/GRPC/MQTT/Option/CLevel.hs b/src/Network/GRPC/MQTT/Option/CLevel.hs index 0d74dc9..f59f4d7 100644 --- a/src/Network/GRPC/MQTT/Option/CLevel.hs +++ b/src/Network/GRPC/MQTT/Option/CLevel.hs @@ -13,10 +13,10 @@ -- Portability : non-portable (GHC extensions) -- -- This module defines the 'CLevel' datatype. 'CLevel' represents a zstandard --- compression level. Zstandard offers compression levels for controlling how +-- compression level. Zstandard offers compression levels for controlling how -- the algorithm favors speed vs. compression ratio. The supported range for a --- compression levels is from 1 to 22. See [the "introduction" section of the --- zstandard documentation] +-- compression levels is from 1 to 22. See [the "introduction" section of the +-- zstandard documentation] -- (https://raw.githack.com/facebook/zstd/release/doc/zstd_manual.html) for more -- information regarding zstandard compression levels. -- @@ -53,7 +53,7 @@ import Data.Data (Data) import Data.List qualified as List -import GHC.Prim (Proxy#, proxy#) +import GHC.Exts (Proxy#, proxy#) import Language.Haskell.TH.Ppr (Ppr, ppr) import Language.Haskell.TH.PprLib qualified as Ppr diff --git a/test/Test.hs b/test/Test.hs index d4b4650..647b153 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedLists #-} -- Copyright (c) 2021 Arista Networks, Inc. @@ -23,7 +24,11 @@ import Test.Tasty.Runners (NumThreads) import Network.GRPC.HighLevel.Client (Host, Port) import Network.MQTT.Topic (Topic) +#if MIN_VERSION_relude(1,1,0) +import Relude +#else import Relude hiding (Option) +#endif --------------------------------------------------------------------------------- diff --git a/test/Test/Proto/Service.hs b/test/Test/Proto/Service.hs index 93d1885..1081c1a 100644 --- a/test/Test/Proto/Service.hs +++ b/test/Test/Proto/Service.hs @@ -10,7 +10,7 @@ where --------------------------------------------------------------------------------- -import Data.ByteString qualified as ByteString +import Data.ByteString qualified as ByteString import Network.GRPC.HighLevel ( MetadataMap, @@ -82,7 +82,7 @@ newTestService = Proto.testServiceServer testServiceHandlers type Handler s rqt rsp = ServerRequest s rqt rsp -> IO (ServerResponse s rsp) -handleClientLongBytes :: Handler 'Normal Message.OneInt Message.BytesResponse +handleClientLongBytes :: Handler 'Normal Message.OneInt Message.BytesResponse handleClientLongBytes (ServerNormalRequest ServerCall{metadata=mm} (Message.OneInt x)) = let response :: Message.BytesResponse response = Message.BytesResponse (ByteString.replicate (1_000_000 * fromIntegral x) 1) @@ -110,7 +110,7 @@ handleClientStream :: Handler 'ClientStreaming Message.OneInt Message.OneInt handleClientStream (ServerReaderRequest _ recv) = loop 0 where loop :: Int32 -> IO (ServerResponse 'ClientStreaming OneInt) - loop ! i = + loop !i = recv >>= \case Left err -> return (newReaderRsp Nothing (show err)) Right Nothing -> do From e95b9d3230321eb78cf8c3471fa8a65c58786ffc Mon Sep 17 00:00:00 2001 From: John Carey Date: Sat, 18 Nov 2023 18:57:31 -0800 Subject: [PATCH 2/4] Allow relude 1.2. --- grpc-mqtt.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grpc-mqtt.cabal b/grpc-mqtt.cabal index 9a1245e..0523f11 100644 --- a/grpc-mqtt.cabal +++ b/grpc-mqtt.cabal @@ -59,7 +59,7 @@ common common , net-mqtt >= 0.8.2 && < 0.9 , proto3-suite >= 0.5.2 && < 0.8 , proto3-wire >= 1.2.2 && < 1.5 - , relude >= 0.7.0 && < 1.2 + , relude >= 0.7.0 && < 1.3 , stm >= 2.5.0 && < 2.6 , text >= 0.2 && < 1.3 || == 2.* , time >= 1.9.3 && < 1.13 From e92fae9bef9215b37ddec73789c8c971105d16ad Mon Sep 17 00:00:00 2001 From: John Carey Date: Sat, 18 Nov 2023 19:32:47 -0800 Subject: [PATCH 3/4] Upgrade data-diverse. --- nix/overlays/haskell.nix | 2 +- nix/packages/data-diverse.nix | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 nix/packages/data-diverse.nix diff --git a/nix/overlays/haskell.nix b/nix/overlays/haskell.nix index e63207e..b7641d7 100644 --- a/nix/overlays/haskell.nix +++ b/nix/overlays/haskell.nix @@ -14,7 +14,7 @@ final: prev: { else final.haskell.lib.doJailbreak (hfinal.callPackage ../packages/chell.nix { }); # The tests in data-diverse do not build with GHC 9.4. - data-diverse = final.haskell.lib.dontCheck hprev.data-diverse; + data-diverse = hfinal.callPackage ../packages/data-diverse.nix { }; # Needed by threadscope-0.2.14.1. ghc-events = hfinal.callPackage ../packages/ghc-events.nix { }; diff --git a/nix/packages/data-diverse.nix b/nix/packages/data-diverse.nix new file mode 100644 index 0000000..52c09ac --- /dev/null +++ b/nix/packages/data-diverse.nix @@ -0,0 +1,16 @@ +{ mkDerivation, base, containers, criterion, deepseq, ghc-prim +, hashable, hspec, lib, tagged +}: +mkDerivation { + pname = "data-diverse"; + version = "4.7.1.0"; + sha256 = "98722c2a85d8a6c2a8fec04820459f32111edb7b20058303d88af3b5ea4f4d80"; + libraryHaskellDepends = [ + base containers deepseq ghc-prim hashable tagged + ]; + testHaskellDepends = [ base hspec tagged ]; + benchmarkHaskellDepends = [ base criterion ]; + homepage = "https://github.com/louispan/data-diverse#readme"; + description = "Extensible records and polymorphic variants"; + license = lib.licenses.bsd3; +} From e5b83dddce035211ec313efeadbf232e2ad63c59 Mon Sep 17 00:00:00 2001 From: John Carey Date: Mon, 20 Nov 2023 10:36:24 -0800 Subject: [PATCH 4/4] Address review comments. --- flake.nix | 2 +- grpc-mqtt.cabal | 2 +- nix/overlays/haskell.nix | 7 +------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index 1e16063..081ca14 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,7 @@ outputs = { self, nixpkgs, flake-utils, gitignore }: flake-utils.lib.eachSystem ["x86_64-linux" "x86_64-darwin"] (system: let - ghc = "ghc8107"; + ghc = "ghc94"; grpcOverlay = import nix/overlays/grpc.nix { }; diff --git a/grpc-mqtt.cabal b/grpc-mqtt.cabal index 0523f11..442b338 100644 --- a/grpc-mqtt.cabal +++ b/grpc-mqtt.cabal @@ -61,7 +61,7 @@ common common , proto3-wire >= 1.2.2 && < 1.5 , relude >= 0.7.0 && < 1.3 , stm >= 2.5.0 && < 2.6 - , text >= 0.2 && < 1.3 || == 2.* + , text >= 0.2 && < 2.2 , time >= 1.9.3 && < 1.13 , turtle < 1.6.0 || >= 1.6.1 && < 1.7.0 , vector >= 0.11 && < 0.13 diff --git a/nix/overlays/haskell.nix b/nix/overlays/haskell.nix index b7641d7..b1cc77c 100644 --- a/nix/overlays/haskell.nix +++ b/nix/overlays/haskell.nix @@ -73,12 +73,7 @@ final: prev: { final.mosquitto hsPkgs.hp2pretty hsPkgs.proto3-suite - ] ++ ( - # threadscope does not yet support template-haskell-2.19, the version for ghc 9.4 - if builtins.compareVersions hsPkgs.ghc.version "9.4" < 0 - then [hsPkgs.threadscope] - else [] - ); + ]; packages = pkgs: [pkgs.grpc-mqtt]; };