From c747c492f2d4d05e5337e32c4ee497132b0eca9f Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Tue, 24 May 2022 12:11:15 +0200 Subject: [PATCH 1/2] Run cabal2nix automatically, no need to commit the result of that. I ran into this because it couldn't find lib in stdenv, when generated these issues shouldn't occur, because nixpkg maintainers deal with that. This also upgrades to the latest nixpkgs --- broch.nix | 36 ------------------------------------ release.nix | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 38 deletions(-) delete mode 100644 broch.nix diff --git a/broch.nix b/broch.nix deleted file mode 100644 index 6486944..0000000 --- a/broch.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ mkDerivation, aeson, aeson-qq, base, blaze-builder, blaze-html -, bytestring, cereal, containers, cookie, cryptonite -, data-default-generics, directory, errors, hspec, http-conduit -, http-types, HUnit, jose-jwt, memory, monad-logger, mtl -, network-uri, optparse-applicative, postgresql-simple, reroute -, resource-pool, sqlite-simple, stdenv, text, time, transformers -, unordered-containers, uri-bytestring, uuid, wai, wai-app-static -, wai-extra, warp -}: -mkDerivation { - pname = "broch"; - version = "0.1"; - src = ./.; - isLibrary = true; - isExecutable = true; - libraryHaskellDepends = [ - aeson base blaze-builder blaze-html bytestring cereal containers - cookie cryptonite data-default-generics directory errors - http-conduit http-types jose-jwt memory mtl postgresql-simple - reroute resource-pool sqlite-simple text time transformers - unordered-containers uri-bytestring uuid wai wai-extra - ]; - executableHaskellDepends = [ - base bytestring cryptonite directory memory monad-logger - optparse-applicative postgresql-simple reroute resource-pool - sqlite-simple text wai-app-static wai-extra warp - ]; - testHaskellDepends = [ - aeson aeson-qq base blaze-builder bytestring containers cookie - cryptonite hspec http-types HUnit jose-jwt memory monad-logger mtl - network-uri sqlite-simple text time transformers - unordered-containers wai wai-extra warp - ]; - description = "OAuth2/OpenID Connect Server"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/release.nix b/release.nix index 5e76952..d9efde5 100644 --- a/release.nix +++ b/release.nix @@ -1,14 +1,30 @@ { compiler ? "default" }: let - pkgs = import {}; + rev = "a790b646e0634695782876f45d98f93c38ceae1d"; + url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; + pkgs = import (builtins.fetchTarball url) {}; dontCheck = pkgs.haskell.lib.dontCheck; + ignore = + let + owner = "hercules-ci"; + repo = "gitignore"; + rev = "c4662e662462e7bf3c2a968483478a665d00e717"; + in + import (builtins.fetchTarball { + url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; + sha256 = "sha256:1npnx0h6bd0d7ql93ka7azhj40zgjp815fw2r6smg8ch9p7mzdlx"; + }) { inherit (pkgs) lib; }; + hPkgs = if compiler == "default" then pkgs.haskellPackages else pkgs.haskell.packages.${compiler}; + src = ignore.gitignoreSource ./.; + lib = pkgs.haskell.lib; haskellPkgs = hPkgs.extend (self: super: { - broch = self.callPackage ./broch.nix {}; + jose-jwt = lib.markUnbroken super.jose-jwt; + broch = self.callCabal2nix "broch" src {}; }); in { From 548be56666a490cc15b8442d96a38952f2e9a0ca Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Tue, 24 May 2022 12:13:33 +0200 Subject: [PATCH 2/2] Add aeson 2 support --- Broch/Server.hs | 3 +-- broch.cabal | 2 +- tests/WaiTest.hs | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Broch/Server.hs b/Broch/Server.hs index adcb7e6..d6281ff 100644 --- a/Broch/Server.hs +++ b/Broch/Server.hs @@ -11,7 +11,6 @@ import Data.ByteArray.Encoding import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Char8 as B -import qualified Data.HashMap.Strict as HM import Data.Int (Int64) import Data.List (intersect, (\\)) import qualified Data.Map.Strict as Map @@ -46,7 +45,7 @@ import Broch.Server.Config import Broch.Server.Internal import Broch.Token import Broch.URI - +import qualified Data.Aeson.KeyMap as HM userIdKey :: ByteString userIdKey = "_uid" diff --git a/broch.cabal b/broch.cabal index 33687e8..a58965e 100644 --- a/broch.cabal +++ b/broch.cabal @@ -42,7 +42,7 @@ Library Other-Modules: Broch.Scim , Broch.Server.BlazeUI Build-Depends: base >= 4.9 && < 5 - , aeson >= 0.8.1.0 + , aeson >= 2.0.0.0 , errors >= 2 , blaze-builder >= 0.3 , blaze-html >= 0.7 diff --git a/tests/WaiTest.hs b/tests/WaiTest.hs index 5438d15..f9271f3 100644 --- a/tests/WaiTest.hs +++ b/tests/WaiTest.hs @@ -14,7 +14,7 @@ import Data.ByteArray.Encoding import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy as BL -import qualified Data.HashMap.Strict as H +import qualified Data.Aeson.KeyMap as H import qualified Data.List as DL import qualified Data.Map as M import Data.Maybe (fromMaybe) @@ -29,6 +29,7 @@ import Network.Wai.Internal import Network.Wai.Test hiding (request) import qualified Test.HUnit as HUnit import qualified Web.Cookie as C +import Data.Aeson.Key -- This code is influenced by yesod-test, but for plain Wai requests. -- The wai-test module by itself only supports simple request testing, @@ -166,7 +167,7 @@ jsonBody = do Success a -> return a _ -> error "Failed to decode JSON" -jsonField :: Text -> WaiTest Text +jsonField :: Key -> WaiTest Text jsonField name = do Object jsn <- jsonContent case H.lookup name jsn of