packages feed

hnix-store-core 0.4.2.0 → 0.4.3.0

raw patch · 8 files changed

+118/−73 lines, 8 filesdep +hspecPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: hspec

API changes (from Hackage documentation)

+ System.Nix.ReadonlyStore: computeStorePathForPath :: StorePathName -> FilePath -> Bool -> (FilePath -> Bool) -> Bool -> IO StorePath
- System.Nix.ReadonlyStore: makeFixedOutputPath :: forall hashAlgo. (ValidAlgo hashAlgo, NamedAlgo hashAlgo) => FilePath -> Bool -> Digest hashAlgo -> StorePathName -> StorePath
+ System.Nix.ReadonlyStore: makeFixedOutputPath :: forall hashAlgo. NamedAlgo hashAlgo => FilePath -> Bool -> Digest hashAlgo -> StorePathName -> StorePath

Files

ChangeLog.md view
@@ -1,5 +1,13 @@ # Revision history for hnix-store-core +## [0.4.3.0](https://github.com/haskell-nix/hnix-store/compare/0.4.2.0...0.4.3.0) 2021-05-30++* Additional:++  * [(link)](https://github.com/haskell-nix/hnix-store/commit/b85f7c875fe6b0bca939ffbcd8b9bd0ab1598aa0) `System.Nix.ReadonlyStore`: add a readonly `computeStorePathForPath`+  * [(link)](https://github.com/haskell-nix/hnix-store/commit/db71ecea3109c0ba270fa98a9041a8556e35217f) `System.Nix.ReadonlyStore`: `computeStorePathForPath`: force SHA256 as it's the only valid choice+  * [(link)](https://github.com/haskell-nix/hnix-store/commit/5fddf3c66ba1bcabb72c4d6b6e09fb41a7acd62c): `makeTextPath`: order the references+ ## [0.4.2.0](https://github.com/haskell-nix/hnix-store/compare/0.4.1.0...0.4.2.0) 2021-03-12  * Additional:
hnix-store-core.cabal view
@@ -1,11 +1,11 @@ cabal-version:       2.2 name:                hnix-store-core-version:             0.4.2.0+version:             0.4.3.0 synopsis:            Core effects for interacting with the Nix store. description:-        This package contains types and functions needed to describe-        interactions with the Nix store abstracted away from-        specific effectful context.+  This package contains types and functions needed to describe+  interactions with the Nix store abstracted away from+  specific effectful context. homepage:            https://github.com/haskell-nix/hnix-store license:             Apache-2.0 license-file:        LICENSE@@ -14,10 +14,11 @@ copyright:           2018 Shea Levy category:            Nix build-type:          Simple-extra-source-files:  ChangeLog.md-                   , README.md-                   , tests/samples/example0.drv-                   , tests/samples/example1.drv+extra-source-files:+    ChangeLog.md+  , README.md+  , tests/samples/example0.drv+  , tests/samples/example1.drv  Common commons   if impl(ghc >= 8.10)@@ -27,47 +28,49 @@  library   import: commons-  exposed-modules:     System.Nix.Base32-                     , System.Nix.Build-                     , System.Nix.Derivation-                     , System.Nix.Hash-                     , System.Nix.Internal.Base32-                     , System.Nix.Internal.Hash-                     , System.Nix.Internal.Nar.Parser-                     , System.Nix.Internal.Nar.Streamer-                     , System.Nix.Internal.Nar.Effects-                     , System.Nix.Internal.Signature-                     , System.Nix.Internal.StorePath-                     , System.Nix.Nar-                     , System.Nix.ReadonlyStore-                     , System.Nix.Signature-                     , System.Nix.StorePath-                     , System.Nix.StorePathMetadata-  build-depends:       base >=4.10 && <5-                     , attoparsec-                     , algebraic-graphs >= 0.5 && < 0.6-                     , base16-bytestring-                     , base64-bytestring-                     , bytestring-                     , cereal-                     , containers-                     , cryptohash-md5-                     , cryptohash-sha1-                     , cryptohash-sha256-                     , cryptohash-sha512-                     , directory-                     , filepath-                     , hashable-                     , lifted-base-                     , monad-control-                     , mtl-                     , nix-derivation >= 1.1.1 && <2-                     , saltine-                     , time-                     , text-                     , unix-                     , unordered-containers-                     , vector+  exposed-modules:+      System.Nix.Base32+    , System.Nix.Build+    , System.Nix.Derivation+    , System.Nix.Hash+    , System.Nix.Internal.Base32+    , System.Nix.Internal.Hash+    , System.Nix.Internal.Nar.Parser+    , System.Nix.Internal.Nar.Streamer+    , System.Nix.Internal.Nar.Effects+    , System.Nix.Internal.Signature+    , System.Nix.Internal.StorePath+    , System.Nix.Nar+    , System.Nix.ReadonlyStore+    , System.Nix.Signature+    , System.Nix.StorePath+    , System.Nix.StorePathMetadata+  build-depends:+      base >=4.10 && <5+    , attoparsec+    , algebraic-graphs >= 0.5 && < 0.6+    , base16-bytestring+    , base64-bytestring+    , bytestring+    , cereal+    , containers+    , cryptohash-md5+    , cryptohash-sha1+    , cryptohash-sha256+    , cryptohash-sha512+    , directory+    , filepath+    , hashable+    , lifted-base+    , monad-control+    , mtl+    , nix-derivation >= 1.1.1 && <2+    , saltine+    , time+    , text+    , unix+    , unordered-containers+    , vector   hs-source-dirs:      src   default-language:    Haskell2010 @@ -79,17 +82,17 @@   import: commons   if flag(bounded_memory)     cpp-options: -DBOUNDED_MEMORY-  ghc-options: -rtsopts -fprof-auto+    ghc-options: -rtsopts -fprof-auto   type: exitcode-stdio-1.0   main-is: Driver.hs   other-modules:-      Arbitrary-      Derivation-      NarFormat-      Hash-      StorePath+    Arbitrary+    Derivation+    NarFormat+    Hash+    StorePath   hs-source-dirs:-      tests+    tests   build-tool-depends:     tasty-discover:tasty-discover   build-depends:@@ -106,6 +109,7 @@     , process     , tasty     , tasty-golden+    , hspec     , tasty-hspec     , tasty-hunit     , tasty-quickcheck
src/System/Nix/Internal/Signature.hs view
@@ -2,6 +2,7 @@ Description : Nix-relevant interfaces to NaCl signatures. -} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE CPP #-}  module System.Nix.Internal.Signature where @@ -11,8 +12,13 @@ import           Data.Coerce                        ( coerce ) import           Crypto.Saltine.Core.Sign           ( PublicKey ) import           Crypto.Saltine.Class               ( IsEncoding(..) )-import qualified Crypto.Saltine.Internal.ByteSizes as NaClSizes +--  2021-05-30: NOTE: Please, clean-up these overloads in ~2022+#if MIN_VERSION_saltine(0,2,0)+import qualified Crypto.Saltine.Internal.Sign as NaClSizes+#else+import qualified Crypto.Saltine.Internal.ByteSizes as NaClSizes+#endif  -- | A NaCl signature. newtype Signature = Signature ByteString@@ -20,7 +26,11 @@  instance IsEncoding Signature where   decode s+#if MIN_VERSION_saltine(0,2,0)+    | Bytes.length s == NaClSizes.sign_bytes = Just $ Signature s+#else     | Bytes.length s == NaClSizes.sign = Just $ Signature s+#endif     | otherwise = Nothing   encode = coerce 
src/System/Nix/ReadonlyStore.hs view
@@ -8,11 +8,14 @@  import           Data.ByteString                ( ByteString ) import qualified Data.ByteString               as BS+import           Data.List                      ( sort ) import qualified Data.Text                     as T import qualified Data.HashSet                  as HS import           Data.Text.Encoding import           System.Nix.Hash+import           System.Nix.Nar import           System.Nix.StorePath+import           Control.Monad.State.Strict   makeStorePath@@ -41,11 +44,11 @@ makeTextPath fp nm h refs = makeStorePath fp ty h nm  where   ty =-    BS.intercalate ":" ("text" : fmap storePathToRawFilePath (HS.toList refs))+    BS.intercalate ":" ("text" : sort (fmap storePathToRawFilePath (HS.toList refs)))  makeFixedOutputPath   :: forall hashAlgo-   . (ValidAlgo hashAlgo, NamedAlgo hashAlgo)+  .  NamedAlgo hashAlgo   => FilePath   -> Bool   -> Digest hashAlgo@@ -57,7 +60,7 @@     else makeStorePath fp "output:out" h'  where   h' =-    hash @ 'SHA256+    hash @'SHA256       $  "fixed:out:"       <> encodeUtf8 (algoName @hashAlgo)       <> (if recursive then ":r:" else ":")@@ -67,3 +70,22 @@ computeStorePathForText   :: FilePath -> StorePathName -> ByteString -> (StorePathSet -> StorePath) computeStorePathForText fp nm = makeTextPath fp nm . hash++computeStorePathForPath+  :: StorePathName        -- ^ Name part of the newly created `StorePath`+  -> FilePath             -- ^ Local `FilePath` to add+  -> Bool                 -- ^ Add target directory recursively+  -> (FilePath -> Bool)   -- ^ Path filter function+  -> Bool                 -- ^ Only used by local store backend+  -> IO StorePath+computeStorePathForPath name pth recursive _pathFilter _repair = do+  selectedHash <- if recursive then recursiveContentHash else flatContentHash+  pure $ makeFixedOutputPath "/nix/store" recursive selectedHash name+ where+  recursiveContentHash :: IO (Digest 'SHA256)+  recursiveContentHash = finalize <$> execStateT streamNarUpdate (initialize @'SHA256)+  streamNarUpdate :: StateT (AlgoCtx 'SHA256) IO ()+  streamNarUpdate = streamNarIO (modify . flip (update @'SHA256)) narEffectsIO pth++  flatContentHash :: IO (Digest 'SHA256)+  flatContentHash = hashLazy <$> narReadFile narEffectsIO pth
tests/Derivation.hs view
@@ -10,7 +10,7 @@                                                 , buildDerivation                                                 ) -import qualified Data.Attoparsec.Text.Lazy+import qualified Data.Attoparsec.Text import qualified Data.Text.IO import qualified Data.Text.Lazy import qualified Data.Text.Lazy.Builder@@ -18,17 +18,18 @@ processDerivation :: FilePath -> FilePath -> IO () processDerivation source dest = do   contents <- Data.Text.IO.readFile source-  case-    Data.Attoparsec.Text.Lazy.parseOnly-      (parseDerivation "/nix/store")-      contents-    of-    Left e -> error e-    Right drv ->+  either+    fail+    (\ drv ->       Data.Text.IO.writeFile dest         . Data.Text.Lazy.toStrict         . Data.Text.Lazy.Builder.toLazyText         $ buildDerivation drv+    )+    (Data.Attoparsec.Text.parseOnly+      (parseDerivation "/nix/store")+      contents+    )  test_derivation :: TestTree test_derivation =
tests/Hash.hs view
@@ -14,7 +14,7 @@ import qualified Data.ByteString.Lazy        as BSL import           Data.Text                   (Text) -import           Test.Tasty.Hspec+import           Test.Hspec import           Test.Tasty.QuickCheck  import           System.Nix.Hash
tests/NarFormat.hs view
@@ -37,7 +37,7 @@ import qualified System.Posix.Process             as Unix import qualified System.Process                   as P import           Test.Tasty                       as T-import           Test.Tasty.Hspec+import           Test.Hspec import qualified Test.Tasty.HUnit                 as HU import           Test.Tasty.QuickCheck import qualified Text.Printf                      as Printf
tests/StorePath.hs view
@@ -5,7 +5,7 @@  module StorePath where -import qualified Data.Attoparsec.Text.Lazy+import qualified Data.Attoparsec.Text  import           Test.Tasty.QuickCheck @@ -24,8 +24,8 @@  prop_storePathRoundtripParser :: NixLike -> NixLike -> Property prop_storePathRoundtripParser (_ :: NixLike) = \(NixLike x) ->-  (Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x+  (Data.Attoparsec.Text.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x  prop_storePathRoundtripParser' :: StorePath -> Property prop_storePathRoundtripParser' x =-  (Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x+  (Data.Attoparsec.Text.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x