makeStorePath: Generalize toall named hash algorithms.

This commit is contained in:
Shea Levy 2019-03-24 16:50:02 -04:00
parent f2beabb10f
commit 61a536504d
No known key found for this signature in database
GPG Key ID: 5C0BD6957D86FE27

View File

@ -11,12 +11,12 @@ import Data.Text.Encoding
import System.Nix.Hash
import System.Nix.StorePath
makeStorePath :: forall storeDir . (KnownStoreDir storeDir) => ByteString -> Digest 'SHA256 -> StorePathName -> StorePath storeDir
makeStorePath :: forall storeDir hashAlgo . (KnownStoreDir storeDir, NamedAlgo hashAlgo) => ByteString -> Digest hashAlgo -> StorePathName -> StorePath storeDir
makeStorePath ty h nm = StorePath storeHash nm
where
s = BS.intercalate ":"
[ ty
, encodeUtf8 $ algoName @'SHA256
, encodeUtf8 $ algoName @hashAlgo
, encodeUtf8 $ encodeBase16 h
, storeDirVal @storeDir
, encodeUtf8 $ unStorePathName nm