@@ -14,8 +14,8 @@ module System.Nix.Internal.StorePath
1414 , StorePath (.. )
1515 , StorePathName (.. )
1616 , StorePathSet
17- , mkStorePathHashPart
1817 , StorePathHashPart (.. )
18+ , mkStorePathHashPart
1919 , ContentAddressableAddress (.. )
2020 , NarHashMode (.. )
2121 , -- * Manipulating 'StorePathName'
@@ -47,6 +47,7 @@ import qualified Data.Attoparsec.Text.Lazy as Parser.Text.Lazy
4747import qualified System.FilePath as FilePath
4848import Crypto.Hash ( SHA256
4949 , Digest
50+ , HashAlgorithm
5051 )
5152
5253-- | A path in a Nix store.
@@ -83,11 +84,18 @@ newtype StorePathName = StorePathName
8384 } deriving (Eq , Hashable , Ord , Show )
8485
8586-- | The hash algorithm used for store path hashes.
86- newtype StorePathHashPart = StorePathHashPart ByteString
87+ newtype StorePathHashPart = StorePathHashPart
88+ { -- | Extract the contents of the hash.
89+ unStorePathHashPart :: ByteString
90+ }
8791 deriving (Eq , Hashable , Ord , Show )
8892
89- mkStorePathHashPart :: ByteString -> StorePathHashPart
90- mkStorePathHashPart = coerce . mkStorePathHash @ SHA256
93+ mkStorePathHashPart
94+ :: forall hashAlgo
95+ . HashAlgorithm hashAlgo
96+ => ByteString
97+ -> StorePathHashPart
98+ mkStorePathHashPart = coerce . mkStorePathHash @ hashAlgo
9199
92100-- | A set of 'StorePath's.
93101type StorePathSet = HashSet StorePath
0 commit comments