diff --git a/hnix.cabal b/hnix.cabal index 88a92b5..a468bb8 100644 --- a/hnix.cabal +++ b/hnix.cabal @@ -910,10 +910,6 @@ library Nix.Options.Parser build-depends: base16-bytestring >= 0.1.1 && < 0.2 - , cryptohash-md5 >= 0.11.100 && < 0.12 - , cryptohash-sha1 >= 0.11.100 && < 0.12 - , cryptohash-sha256 >= 0.11.101 && < 0.12 - , cryptohash-sha512 >= 0.11.100 && < 0.12 , haskeline >= 0.7.4.2 && < 0.8 , pretty-show >= 1.9.5 && < 1.11 , serialise >= 0.2.1 && < 0.3 @@ -937,16 +933,11 @@ executable hnix , bytestring , comonad , containers - , cryptohash-md5 - , cryptohash-sha1 - , cryptohash-sha256 - , cryptohash-sha512 , data-fix , deepseq , exceptions , filepath , free - , hashing , haskeline , hnix , mtl @@ -989,17 +980,12 @@ test-suite hnix-tests , base16-bytestring , bytestring , containers - , cryptohash-md5 - , cryptohash-sha1 - , cryptohash-sha256 - , cryptohash-sha512 , data-fix , deepseq >=1.4.3 && <1.5 , directory , exceptions , filepath , generic-random - , hashing , hedgehog , hnix , interpolate @@ -1043,15 +1029,10 @@ benchmark hnix-benchmarks , bytestring , containers , criterion - , cryptohash-md5 - , cryptohash-sha1 - , cryptohash-sha256 - , cryptohash-sha512 , data-fix , deepseq >=1.4.3 && <1.5 , exceptions , filepath - , hashing , hnix , mtl , optparse-applicative diff --git a/src/Nix/Builtins.hs b/src/Nix/Builtins.hs index 6017592..3c7b78a 100644 --- a/src/Nix/Builtins.hs +++ b/src/Nix/Builtins.hs @@ -30,23 +30,11 @@ import Control.Monad import Control.Monad.Catch import Control.Monad.ListM ( sortByM ) import Control.Monad.Reader ( asks ) - --- Using package imports here because there is a bug in cabal2nix that demands --- us to put the hashing package in the unconditional dependency list. --- See https://github.com/NixOS/cabal2nix/issues/348 for more info -#if MIN_VERSION_hashing(0, 1, 0) -import "hashing" Crypto.Hash -import qualified "hashing" Crypto.Hash.MD5 as MD5 -import qualified "hashing" Crypto.Hash.SHA1 as SHA1 -import qualified "hashing" Crypto.Hash.SHA256 as SHA256 -import qualified "hashing" Crypto.Hash.SHA512 as SHA512 -#else -import qualified "cryptohash-md5" Crypto.Hash.MD5 as MD5 -import qualified "cryptohash-sha1" Crypto.Hash.SHA1 as SHA1 -import qualified "cryptohash-sha256" Crypto.Hash.SHA256 as SHA256 -import qualified "cryptohash-sha512" Crypto.Hash.SHA512 as SHA512 -#endif - +import Crypto.Hash +import qualified Crypto.Hash.MD5 as MD5 +import qualified Crypto.Hash.SHA1 as SHA1 +import qualified Crypto.Hash.SHA256 as SHA256 +import qualified Crypto.Hash.SHA512 as SHA512 import qualified Data.Aeson as A import Data.Align ( alignWith ) import Data.Array @@ -1208,32 +1196,16 @@ hashString nsAlgo ns = Prim $ do case algo of "md5" -> f $ \s -> -#if MIN_VERSION_hashing(0, 1, 0) Text.pack $ show (hash (encodeUtf8 s) :: MD5.MD5) -#else - decodeUtf8 $ Base16.encode $ MD5.hash $ encodeUtf8 s -#endif "sha1" -> f $ \s -> -#if MIN_VERSION_hashing(0, 1, 0) Text.pack $ show (hash (encodeUtf8 s) :: SHA1.SHA1) -#else - decodeUtf8 $ Base16.encode $ SHA1.hash $ encodeUtf8 s -#endif "sha256" -> f $ \s -> -#if MIN_VERSION_hashing(0, 1, 0) Text.pack $ show (hash (encodeUtf8 s) :: SHA256.SHA256) -#else - decodeUtf8 $ Base16.encode $ SHA256.hash $ encodeUtf8 s -#endif "sha512" -> f $ \s -> -#if MIN_VERSION_hashing(0, 1, 0) Text.pack $ show (hash (encodeUtf8 s) :: SHA512.SHA512) -#else - decodeUtf8 $ Base16.encode $ SHA512.hash $ encodeUtf8 s -#endif _ -> throwError $ ErrorCall