Skip to content

Commit b60f83e

Browse files
committed
cabal: dep: hnix-store-{core,remote} (0.4->0.5)
For simplicity (& because we are already in massive breackage) chosen to just migrate to 0.5. HNix currently winded-up wih 2 hashing packages, but what to choose would be seen further down the line, it is smart to postphone in this case.
1 parent eae27ee commit b60f83e

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed

default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ let
192192

193193
semialign = super.semialign_1_2;
194194
relude = super.relude_1_0_0_1;
195+
hnix-store-core = super.hnix-store-core_0_5_0_0;
196+
hnix-store-remote = super.hnix-store-remote_0_5_0_0;
195197

196198
};
197199

hnix.cabal

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ library
410410
, base16-bytestring >= 0.1.1 && < 1.1
411411
, binary >= 0.8.5 && < 0.9
412412
, bytestring >= 0.10.8 && < 0.12
413+
, cryptonite
413414
, comonad >= 5.0.4 && < 5.1
414415
, containers >= 0.5.11.0 && < 0.7
415416
, data-fix >= 0.3.0 && < 0.4
@@ -422,8 +423,8 @@ library
422423
, gitrev >= 1.1.0 && < 1.4
423424
, hashable >= 1.2.5 && < 1.4
424425
, hashing >= 0.1.0 && < 0.2
425-
, hnix-store-core >= 0.4.0 && < 0.5
426-
, hnix-store-remote >= 0.4.0 && < 0.5
426+
, hnix-store-core >= 0.5.0 && < 0.6
427+
, hnix-store-remote >= 0.5.0 && < 0.6
427428
, http-client >= 0.5.14 && < 0.6 || >= 0.6.4 && < 0.8
428429
, http-client-tls >= 0.3.5 && < 0.4
429430
, http-types >= 0.12.2 && < 0.13

src/Nix/Builtins.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{-# LANGUAGE TemplateHaskell #-}
1313
{-# LANGUAGE UndecidableInstances #-}
1414
{-# LANGUAGE ViewPatterns #-}
15+
{-# LANGUAGE PackageImports #-} -- 2021-07-05: Due to hashing Haskell IT system situation, in HNix we currently ended-up with 2 hash package dependencies @{hashing, cryptonite}@
1516

1617
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
1718

@@ -30,11 +31,11 @@ import Control.Comonad ( Comonad )
3031
import Control.Monad ( foldM )
3132
import Control.Monad.Catch ( MonadCatch(catch) )
3233
import Control.Monad.ListM ( sortByM )
33-
import Crypto.Hash
34-
import qualified Crypto.Hash.MD5 as MD5
35-
import qualified Crypto.Hash.SHA1 as SHA1
36-
import qualified Crypto.Hash.SHA256 as SHA256
37-
import qualified Crypto.Hash.SHA512 as SHA512
34+
import "hashing" Crypto.Hash
35+
import qualified "hashing" Crypto.Hash.MD5 as MD5
36+
import qualified "hashing" Crypto.Hash.SHA1 as SHA1
37+
import qualified "hashing" Crypto.Hash.SHA256 as SHA256
38+
import qualified "hashing" Crypto.Hash.SHA512 as SHA512
3839
import qualified Data.Aeson as A
3940
import Data.Align ( alignWith )
4041
import Data.Array

src/Nix/Effects.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{-# LANGUAGE DataKinds #-}
66
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
77
{-# LANGUAGE UndecidableInstances #-}
8+
{-# LANGUAGE PackageImports #-} -- 2021-07-05: Due to hashing Haskell IT system situation, in HNix we currently ended-up with 2 hash package dependencies @{hashing, cryptonite}@
89

910
{-# OPTIONS_GHC -Wno-orphans #-}
1011

@@ -23,6 +24,7 @@ import qualified Data.Text as Text
2324
import Network.HTTP.Client hiding ( path, Proxy )
2425
import Network.HTTP.Client.TLS
2526
import Network.HTTP.Types
27+
import qualified "cryptonite" Crypto.Hash as Hash
2628
import Nix.Utils.Fix1
2729
import Nix.Expr
2830
import Nix.Frames hiding ( Proxy )
@@ -36,7 +38,6 @@ import System.FilePath ( takeFileName )
3638
import qualified System.Info
3739
import System.Process
3840

39-
import qualified System.Nix.Hash as Store
4041
import qualified System.Nix.Store.Remote as Store.Remote
4142
import qualified System.Nix.StorePath as Store
4243

@@ -402,7 +403,7 @@ instance MonadStore IO where
402403
(\ pathName ->
403404
do
404405
-- TODO: redesign the filter parameter
405-
res <- Store.Remote.runStore $ Store.Remote.addToStore @'Store.SHA256 pathName path recursive (const False) repair
406+
res <- Store.Remote.runStore $ Store.Remote.addToStore @Hash.SHA256 pathName path recursive (const False) repair
406407
either
407408
Left -- err
408409
(pure . StorePath . decodeUtf8 . Store.storePathToRawFilePath) -- store path

src/Nix/Effects/Derivation.hs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{-# LANGUAGE NamedFieldPuns #-}
33
{-# LANGUAGE RecordWildCards #-}
44
{-# LANGUAGE ScopedTypeVariables #-}
5-
5+
{-# LANGUAGE PackageImports #-} -- 2021-07-05: Due to hashing Haskell IT system situation, in HNix we currently ended-up with 2 hash package dependencies @{hashing, cryptonite}@
66

77
module Nix.Effects.Derivation ( defaultDerivationStrict ) where
88

@@ -18,6 +18,11 @@ import qualified Data.Map.Strict as Map
1818
import qualified Data.Set as Set
1919
import qualified Data.Text as Text
2020

21+
import Text.Megaparsec
22+
import Text.Megaparsec.Char
23+
24+
import qualified "cryptonite" Crypto.Hash as Hash -- 2021-07-05: Attrocity of Haskell hashing situation, in HNix we ended-up with 2 hash package dependencies @{hashing, cryptonite}@
25+
2126
import Nix.Atoms
2227
import Nix.Convert
2328
import Nix.Effects
@@ -35,9 +40,6 @@ import Nix.Value.Monad
3540
import qualified System.Nix.ReadonlyStore as Store
3641
import qualified System.Nix.Hash as Store
3742
import qualified System.Nix.StorePath as Store
38-
39-
import Text.Megaparsec
40-
import Text.Megaparsec.Char
4143
import Prelude hiding (readFile)
4244

4345

@@ -77,21 +79,21 @@ writeDerivation drv@Derivation{inputs, name} = do
7779

7880
-- | Traverse the graph of inputDrvs to replace fixed output derivations with their fixed output hash.
7981
-- this avoids propagating changes to their .drv when the output hash stays the same.
80-
hashDerivationModulo :: (MonadNix e t f m, MonadState (b, AttrSet Text) m) => Derivation -> m (Store.Digest 'Store.SHA256)
82+
hashDerivationModulo :: (MonadNix e t f m, MonadState (b, AttrSet Text) m) => Derivation -> m (Hash.Digest Hash.SHA256)
8183
hashDerivationModulo
8284
Derivation
83-
{ mFixed = Just (Store.SomeDigest (digest :: Store.Digest hashType))
85+
{ mFixed = Just (Store.SomeDigest (digest :: Hash.Digest hashType))
8486
, outputs
8587
, hashMode
8688
} =
8789
case Map.toList outputs of
8890
[("out", path)] -> pure $
89-
Store.hash @'Store.SHA256 $
91+
Hash.hash @ByteString @Hash.SHA256 $
9092
encodeUtf8 $
9193
"fixed:out"
9294
<> (if hashMode == Recursive then ":r" else "")
9395
<> ":" <> (Store.algoName @hashType)
94-
<> ":" <> Store.encodeInBase Store.Base16 digest
96+
<> ":" <> Store.encodeDigestWith Store.Base16 digest
9597
<> ":" <> path
9698
_outputsList -> throwError $ ErrorCall $ "This is weird. A fixed output drv should only have one output named 'out'. Got " <> show _outputsList
9799
hashDerivationModulo
@@ -109,14 +111,14 @@ hashDerivationModulo
109111
maybe
110112
(do
111113
drv' <- readDerivation $ toString path
112-
hash <- Store.encodeInBase Store.Base16 <$> hashDerivationModulo drv'
114+
hash <- Store.encodeDigestWith Store.Base16 <$> hashDerivationModulo drv'
113115
pure (hash, outs)
114116
)
115117
(\ hash -> pure (hash, outs))
116118
(M.lookup path cache)
117119
)
118120
(Map.toList inputDrvs)
119-
pure $ Store.hash @'Store.SHA256 $ encodeUtf8 $ unparseDrv (drv {inputs = (inputSrcs, inputsModulo)})
121+
pure $ Hash.hash @ByteString @Hash.SHA256 $ encodeUtf8 $ unparseDrv $ drv {inputs = (inputSrcs, inputsModulo)}
120122

121123
unparseDrv :: Derivation -> Text
122124
unparseDrv Derivation{..} =
@@ -146,8 +148,8 @@ unparseDrv Derivation{..} =
146148
parens $ (s <$>) $ ([outputName, outputPath] <>) $
147149
maybe
148150
[mempty, mempty]
149-
(\ (Store.SomeDigest (digest :: Store.Digest hashType)) ->
150-
[prefix <> Store.algoName @hashType, Store.encodeInBase Store.Base16 digest]
151+
(\ (Store.SomeDigest (digest :: Hash.Digest hashType)) ->
152+
[prefix <> Store.algoName @hashType, Store.encodeDigestWith Store.Base16 digest]
151153
)
152154
mFixed
153155
parens :: [Text] -> Text
@@ -279,7 +281,7 @@ defaultDerivationStrict val = do
279281
drvPath <- pathToText <$> writeDerivation drv'
280282

281283
-- Memoize here, as it may be our last chance in case of readonly stores.
282-
drvHash <- Store.encodeInBase Store.Base16 <$> hashDerivationModulo drv'
284+
drvHash <- Store.encodeDigestWith Store.Base16 <$> hashDerivationModulo drv'
283285
modify $ second $ MS.insert drvPath drvHash
284286

285287
let

0 commit comments

Comments
 (0)