From c4339a029e163ed3d319847558bb3af26250341c Mon Sep 17 00:00:00 2001 From: Oliver Charles Date: Thu, 3 Apr 2014 14:25:37 +0100 Subject: [PATCH] haskellPackages.twitterConduit: New expression I've had to patch authenticate-oauth to get this working. The patch comes from a commit that's already in master, so future versions will have this and it's ok if cabal2nix ends up discarding this information. --- .../haskell/authenticate-oauth/RSA2.patch | 57 +++++++++++++++++++ .../haskell/authenticate-oauth/default.nix | 3 + .../haskell/twitter-conduit/default.nix | 28 +++++++++ .../haskell/twitter-types/default.nix | 23 ++++++++ pkgs/top-level/haskell-packages.nix | 4 ++ 5 files changed, 115 insertions(+) create mode 100644 pkgs/development/libraries/haskell/authenticate-oauth/RSA2.patch create mode 100644 pkgs/development/libraries/haskell/twitter-conduit/default.nix create mode 100644 pkgs/development/libraries/haskell/twitter-types/default.nix diff --git a/pkgs/development/libraries/haskell/authenticate-oauth/RSA2.patch b/pkgs/development/libraries/haskell/authenticate-oauth/RSA2.patch new file mode 100644 index 00000000000..6a888aa3277 --- /dev/null +++ b/pkgs/development/libraries/haskell/authenticate-oauth/RSA2.patch @@ -0,0 +1,57 @@ +From c401c2c585b5345243211e981c123a92b995b448 Mon Sep 17 00:00:00 2001 +From: Sergei Trofimovich +Date: Sat, 25 Jan 2014 13:35:52 +0300 +Subject: [PATCH] authenticate-oauth.cabal: allow RSA-2 + +The only cosmetic change is rename of 'ha_SHA1' to 'hashSHA1' + +Signed-off-by: Sergei Trofimovich +--- + authenticate-oauth/Web/Authenticate/OAuth.hs | 10 ++++++++-- + authenticate-oauth/authenticate-oauth.cabal | 2 +- + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/authenticate-oauth/Web/Authenticate/OAuth.hs b/authenticate-oauth/Web/Authenticate/OAuth.hs +index 3f38c8c..eccd0f1 100644 +--- a/authenticate-oauth/Web/Authenticate/OAuth.hs ++++ b/authenticate-oauth/Web/Authenticate/OAuth.hs +@@ -21,7 +21,7 @@ module Web.Authenticate.OAuth + paramEncode, addScope, addMaybeProxy + ) where + import Blaze.ByteString.Builder (toByteString, Builder) +-import Codec.Crypto.RSA (ha_SHA1, rsassa_pkcs1_v1_5_sign) ++import qualified Codec.Crypto.RSA as RSA + import Control.Exception + import Control.Monad + import Control.Monad.IO.Class (MonadIO, liftIO) +@@ -346,7 +346,13 @@ genSign oa tok req = + PLAINTEXT -> + return $ BS.intercalate "&" $ map paramEncode [oauthConsumerSecret oa, tokenSecret tok] + RSASHA1 pr -> +- liftM (encode . toStrict . rsassa_pkcs1_v1_5_sign ha_SHA1 pr) (getBaseString tok req) ++ liftM (encode . toStrict . RSA.rsassa_pkcs1_v1_5_sign ++#if MIN_VERSION_RSA(2, 0, 0) ++ RSA.hashSHA1 ++#else ++ RSA.ha_SHA1 ++#endif ++ pr) (getBaseString tok req) + + #if MIN_VERSION_http_conduit(2, 0, 0) + addAuthHeader :: BS.ByteString -> Credential -> Request -> Request +diff --git a/authenticate-oauth/authenticate-oauth.cabal b/authenticate-oauth/authenticate-oauth.cabal +index 00507da..e11c3bd 100644 +--- a/authenticate-oauth/authenticate-oauth.cabal ++++ b/authenticate-oauth/authenticate-oauth.cabal +@@ -19,7 +19,7 @@ library + , transformers >= 0.1 && < 0.4 + , bytestring >= 0.9 + , crypto-pubkey-types >= 0.1 && < 0.5 +- , RSA >= 1.2 && < 1.3 ++ , RSA >= 1.2 && < 2.1 + , time + , data-default + , base64-bytestring >= 0.1 && < 1.1 +-- +1.9.1 + diff --git a/pkgs/development/libraries/haskell/authenticate-oauth/default.nix b/pkgs/development/libraries/haskell/authenticate-oauth/default.nix index 15c8267ca3e..9a75bd0cea5 100644 --- a/pkgs/development/libraries/haskell/authenticate-oauth/default.nix +++ b/pkgs/development/libraries/haskell/authenticate-oauth/default.nix @@ -7,6 +7,8 @@ cabal.mkDerivation (self: { pname = "authenticate-oauth"; version = "1.4.0.8"; sha256 = "1mc36d6lkmqywzsxhzwv4445mmwdz0rr5ibd2a1nbgw5c5jw76fy"; + patches = [ ./RSA2.patch ]; + patchFlags = "-p2"; buildDepends = [ base64Bytestring blazeBuilder blazeBuilderConduit conduit cryptoPubkeyTypes dataDefault httpConduit httpTypes monadControl @@ -17,5 +19,6 @@ cabal.mkDerivation (self: { description = "Library to authenticate with OAuth for Haskell web applications"; license = self.stdenv.lib.licenses.bsd3; platforms = self.ghc.meta.platforms; + maintainers = [ self.stdenv.lib.maintainers.ocharles ]; }; }) diff --git a/pkgs/development/libraries/haskell/twitter-conduit/default.nix b/pkgs/development/libraries/haskell/twitter-conduit/default.nix new file mode 100644 index 00000000000..d3985877077 --- /dev/null +++ b/pkgs/development/libraries/haskell/twitter-conduit/default.nix @@ -0,0 +1,28 @@ +{ cabal, aeson, attoparsec, attoparsecConduit, authenticateOauth +, conduit, dataDefault, doctest, failure, filepath, hlint +, httpClientMultipart, httpConduit, httpTypes, lens, liftedBase +, monadControl, monadLogger, resourcet, shakespeareText, text, time +, transformers, transformersBase, twitterTypes +}: + +cabal.mkDerivation (self: { + pname = "twitter-conduit"; + version = "0.0.2"; + sha256 = "1bkn0lfwwr5lnw4xfzdjiad48r1qz6m4z0nq1inz45gflmjwmghj"; + isLibrary = true; + isExecutable = true; + buildDepends = [ + aeson attoparsec attoparsecConduit authenticateOauth conduit + dataDefault failure httpClientMultipart httpConduit httpTypes lens + liftedBase monadControl monadLogger resourcet shakespeareText text + time transformers transformersBase twitterTypes + ]; + testDepends = [ doctest filepath hlint ]; + meta = { + homepage = "https://github.com/himura/twitter-conduit"; + description = "Twitter API package with conduit interface and Streaming API support"; + license = self.stdenv.lib.licenses.bsd3; + platforms = self.ghc.meta.platforms; + maintainers = [ self.stdenv.lib.maintainers.ocharles ]; + }; +}) diff --git a/pkgs/development/libraries/haskell/twitter-types/default.nix b/pkgs/development/libraries/haskell/twitter-types/default.nix new file mode 100644 index 00000000000..299d39c4546 --- /dev/null +++ b/pkgs/development/libraries/haskell/twitter-types/default.nix @@ -0,0 +1,23 @@ +{ cabal, aeson, attoparsec, httpTypes, HUnit, shakespeareText +, testFramework, testFrameworkHunit, testFrameworkThPrime, text +, unorderedContainers +}: + +cabal.mkDerivation (self: { + pname = "twitter-types"; + version = "0.2.20130101"; + sha256 = "0y7pymwcv8i5f8hqh4h018xp5bd998l8fx9f2a8x6d53c7l34wmd"; + buildDepends = [ aeson httpTypes text unorderedContainers ]; + testDepends = [ + aeson attoparsec httpTypes HUnit shakespeareText testFramework + testFrameworkHunit testFrameworkThPrime text unorderedContainers + ]; + meta = { + homepage = "https://github.com/himura/twitter-types"; + description = "Twitter JSON parser and types"; + license = self.stdenv.lib.licenses.bsd3; + platforms = self.ghc.meta.platforms; + maintainers = [ self.stdenv.lib.maintainers.ocharles ]; + }; + doCheck = false; +}) diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index 64bf6e18e0e..a963dd2b1e6 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -2522,6 +2522,10 @@ let result = let callPackage = x : y : modifyPrio (newScope result.finalReturn x tuple = callPackage ../development/libraries/haskell/tuple {}; + twitterConduit = callPackage ../development/libraries/haskell/twitter-conduit {}; + + twitterTypes = callPackage ../development/libraries/haskell/twitter-types {}; + TypeCompose = callPackage ../development/libraries/haskell/TypeCompose {}; typeEq = callPackage ../development/libraries/haskell/type-eq {};