Skip to content

Commit db71ece

Browse files
layussorki
authored andcommitted
computeStorePathForPath: force SHA256 as it's the only valid choice
1 parent b85f7c8 commit db71ece

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

hnix-store-core/src/System/Nix/ReadonlyStore.hs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
{-# LANGUAGE OverloadedStrings #-}
33
{-# LANGUAGE TypeApplications #-}
44
{-# LANGUAGE ScopedTypeVariables #-}
5-
{-# LANGUAGE AllowAmbiguousTypes #-}
6-
{-# LANGUAGE TypeFamilies #-}
75

86
module System.Nix.ReadonlyStore where
97

@@ -50,9 +48,7 @@ makeTextPath fp nm h refs = makeStorePath fp ty h nm
5048

5149
makeFixedOutputPath
5250
:: forall hashAlgo
53-
. ( ValidAlgo hashAlgo
54-
, NamedAlgo hashAlgo
55-
)
51+
. NamedAlgo hashAlgo
5652
=> FilePath
5753
-> Bool
5854
-> Digest hashAlgo
@@ -75,21 +71,21 @@ computeStorePathForText
7571
:: FilePath -> StorePathName -> ByteString -> (StorePathSet -> StorePath)
7672
computeStorePathForText fp nm = makeTextPath fp nm . hash
7773

78-
computeStorePathForPath :: forall a. (ValidAlgo a, NamedAlgo a)
79-
=> StorePathName -- ^ Name part of the newly created `StorePath`
80-
-> FilePath -- ^ Local `FilePath` to add
81-
-> Bool -- ^ Add target directory recursively
82-
-> (FilePath -> Bool) -- ^ Path filter function
83-
-> Bool -- ^ Only used by local store backend
84-
-> IO StorePath
74+
computeStorePathForPath
75+
:: StorePathName -- ^ Name part of the newly created `StorePath`
76+
-> FilePath -- ^ Local `FilePath` to add
77+
-> Bool -- ^ Add target directory recursively
78+
-> (FilePath -> Bool) -- ^ Path filter function
79+
-> Bool -- ^ Only used by local store backend
80+
-> IO StorePath
8581
computeStorePathForPath name pth recursive _pathFilter _repair = do
8682
selectedHash <- if recursive then recursiveContentHash else flatContentHash
8783
pure $ makeFixedOutputPath "/nix/store" recursive selectedHash name
8884
where
89-
recursiveContentHash :: IO (Digest a)
90-
recursiveContentHash = finalize @a <$> execStateT streamNarUpdate (initialize @a)
91-
streamNarUpdate :: StateT (AlgoCtx a) IO ()
92-
streamNarUpdate = streamNarIO (modify . flip (update @a)) narEffectsIO pth
85+
recursiveContentHash :: IO (Digest 'SHA256)
86+
recursiveContentHash = finalize <$> execStateT streamNarUpdate (initialize @'SHA256)
87+
streamNarUpdate :: StateT (AlgoCtx 'SHA256) IO ()
88+
streamNarUpdate = streamNarIO (modify . flip (update @'SHA256)) narEffectsIO pth
9389

94-
flatContentHash :: IO (Digest a)
90+
flatContentHash :: IO (Digest 'SHA256)
9591
flatContentHash = hashLazy <$> narReadFile narEffectsIO pth

0 commit comments

Comments
 (0)