hnix-store-remote 0.4.3.1 → 0.5.0.0
raw patch · 7 files changed
+36/−27 lines, 7 filesdep +cryptonitedep ~hnix-store-corePVP ok
version bump matches the API change (PVP)
Dependencies added: cryptonite
Dependency ranges changed: hnix-store-core
API changes (from Hackage documentation)
- System.Nix.Store.Remote: addToStore :: forall a. (ValidAlgo a, NamedAlgo a) => StorePathName -> FilePath -> Bool -> (FilePath -> Bool) -> RepairFlag -> MonadStore StorePath
+ System.Nix.Store.Remote: addToStore :: forall a. NamedAlgo a => StorePathName -> FilePath -> Bool -> (FilePath -> Bool) -> RepairFlag -> MonadStore StorePath
- System.Nix.Store.Remote: queryPathFromHashPart :: Digest StorePathHashAlgo -> MonadStore StorePath
+ System.Nix.Store.Remote: queryPathFromHashPart :: StorePathHashPart -> MonadStore StorePath
Files
- ChangeLog.md +7/−0
- hnix-store-remote.cabal +4/−2
- src/System/Nix/Store/Remote.hs +13/−11
- src/System/Nix/Store/Remote/Builders.hs +3/−6
- src/System/Nix/Store/Remote/Parsers.hs +2/−1
- tests/Derivation.hs +2/−3
- tests/NixDaemon.hs +5/−4
ChangeLog.md view
@@ -1,5 +1,12 @@ # Revision history for hnix-store-remote +## [0.5.0.0](https://github.com/haskell-nix/hnix-store/compare/0.4.3.0...0.5.0.0) 2021-06-11++* Breaking:+ * [(link)](https://github.com/haskell-nix/hnix-store/commit/3b948d112aa9307b0451258f28c7ee5dc86b24c7) `System.Nix.Store.Remote`:+ * `addToStore`: constraint of `ValidAlgo a` removed in favour of constraint on `cryptonite: HashAlgorithm a` through constraint `NamedAlgo a`.+ * `queryPathFromHashPart`: 1st arg changed from `Digest StorePathHashAlgo` to `StorePathHashPart`, for details: [hnix-store-core 0.5.0.0 ChangeLog](https://hackage.haskell.org/package/hnix-store-core-0.5.0.0/changelog).+ ## [0.4.3.0](https://github.com/haskell-nix/hnix-store/compare/0.4.2.0...0.4.3.0) 2021-05-30 Nothing (it is tandem `hnix-store-core` fix release)
hnix-store-remote.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: hnix-store-remote-version: 0.4.3.1+version: 0.5.0.0 synopsis: Remote hnix store description: Implementation of the nix store using the daemon protocol. homepage: https://github.com/haskell-nix/hnix-store@@ -44,13 +44,14 @@ , binary , bytestring , containers+ , cryptonite , text , time , network , nix-derivation >= 1.1.1 && <2 , mtl , unordered-containers- , hnix-store-core >= 0.4 && <0.5+ , hnix-store-core >= 0.5 && <0.6 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall@@ -77,6 +78,7 @@ , hnix-store-core >= 0.3 , hnix-store-remote , containers+ , cryptonite , directory , process , filepath
src/System/Nix/Store/Remote.hs view
@@ -47,20 +47,20 @@ import System.Nix.Build ( BuildMode , BuildResult )-import System.Nix.Hash ( Digest- , NamedAlgo- , ValidAlgo+import System.Nix.Hash ( NamedAlgo , SomeNamedDigest(..)- , BaseEncoding(Base32)+ , BaseEncoding(NixBase32)+ , decodeDigestWith ) import System.Nix.StorePath ( StorePath , StorePathName , StorePathSet- , StorePathHashAlgo+ , StorePathHashPart ) import System.Nix.StorePathMetadata ( StorePathMetadata(..) , StorePathTrust(..) )+import System.Nix.Internal.Base ( encodeWith ) import qualified Data.Binary.Put import qualified Data.ByteString.Lazy@@ -77,6 +77,8 @@ import System.Nix.Store.Remote.Types import System.Nix.Store.Remote.Protocol import System.Nix.Store.Remote.Util+import Crypto.Hash ( SHA256 )+import Data.Coerce ( coerce ) type RepairFlag = Bool type CheckFlag = Bool@@ -85,7 +87,7 @@ -- | Pack `FilePath` as `Nar` and add it to the store. addToStore :: forall a- . (ValidAlgo a, NamedAlgo a)+ . NamedAlgo a => StorePathName -- ^ Name part of the newly created `StorePath` -> FilePath -- ^ Local `FilePath` to add -> Bool -- ^ Add target directory recursively@@ -167,9 +169,9 @@ -- but without it protocol just hangs waiting for -- more data. Needs investigation. -- Intentionally the only warning that should pop-up.- putInt 0+ putInt (0 :: Integer) - res <- getSocketIncremental $ getBuildResult+ res <- getSocketIncremental getBuildResult pure res ensurePath :: StorePath -> MonadStore ()@@ -237,7 +239,7 @@ let narHash = case- System.Nix.Hash.decodeBase @'System.Nix.Hash.SHA256 Base32 narHashText+ decodeDigestWith @SHA256 NixBase32 narHashText of Left e -> error e Right x -> SomeDigest x@@ -285,13 +287,13 @@ runOpArgs QueryDerivationOutputNames $ putPath p sockGetPaths -queryPathFromHashPart :: Digest StorePathHashAlgo -> MonadStore StorePath+queryPathFromHashPart :: StorePathHashPart -> MonadStore StorePath queryPathFromHashPart storePathHash = do runOpArgs QueryPathFromHashPart $ putByteStringLen $ Data.ByteString.Lazy.fromStrict $ Data.Text.Encoding.encodeUtf8- $ System.Nix.Hash.encodeInBase Base32 storePathHash+ $ encodeWith NixBase32 $ coerce storePathHash sockGetPath queryMissing
src/System/Nix/Store/Remote/Builders.hs view
@@ -10,17 +10,14 @@ where import Data.Text.Lazy ( Text )-import System.Nix.Hash ( Digest- , SomeNamedDigest(SomeDigest)- , BaseEncoding(Base32)- )+import Crypto.Hash ( Digest ) import System.Nix.StorePath ( ContentAddressableAddress(..) ) import Data.Text.Lazy.Builder ( Builder ) import qualified Data.Text.Lazy.Builder -import qualified System.Nix.Hash+import System.Nix.Hash -- | Marshall `ContentAddressableAddress` to `Text` -- in form suitable for remote protocol usage.@@ -38,4 +35,4 @@ digestBuilder :: Digest a -> Builder digestBuilder =- Data.Text.Lazy.Builder.fromText . System.Nix.Hash.encodeInBase Base32+ Data.Text.Lazy.Builder.fromText . encodeDigestWith NixBase32
src/System/Nix/Store/Remote/Parsers.hs view
@@ -19,6 +19,7 @@ import System.Nix.StorePath ( ContentAddressableAddress(..) , NarHashMode(..) )+import Crypto.Hash ( SHA256 ) -- | Parse `ContentAddressableAddress` from `ByteString` parseContentAddressableAddress@@ -34,7 +35,7 @@ caText :: Parser ContentAddressableAddress caText = do _ <- "text:sha256:"- digest <- decodeBase @'SHA256 Base32 <$> parseHash+ digest <- decodeDigestWith @SHA256 NixBase32 <$> parseHash either fail pure $ Text <$> digest -- | Parser for @fixed:<r?>:<ht>:<h>@
tests/Derivation.hs view
@@ -18,8 +18,6 @@ , addToStore , addTextToStore )-import System.Nix.Hash ( HashAlgorithm(SHA256) )- import qualified Data.Map import qualified Data.Set import qualified Data.Text@@ -29,6 +27,7 @@ import qualified System.Nix.Derivation import qualified System.Nix.StorePath import qualified System.Directory+import Crypto.Hash ( SHA256 ) drvSample :: StorePath -> StorePath -> StorePath -> Derivation StorePath Text drvSample builder' buildScript out = Derivation@@ -48,7 +47,7 @@ Nothing -> error "No bash executable found" Just fp -> do let Right n = System.Nix.StorePath.makeStorePathName "bash"- pth <- addToStore @'SHA256 n fp False (pure True) False+ pth <- addToStore @SHA256 n fp False (pure True) False action pth withBuildScript :: (StorePath -> MonadStore a) -> MonadStore a
tests/NixDaemon.hs view
@@ -32,12 +32,13 @@ import System.FilePath import System.Nix.Build-import System.Nix.Hash import System.Nix.StorePath import System.Nix.Store.Remote import System.Nix.Store.Remote.Protocol import Derivation+import Crypto.Hash ( SHA256+ ) createProcessEnv :: FilePath -> String -> [String] -> IO P.ProcessHandle createProcessEnv fp proc args = do@@ -167,13 +168,13 @@ dummy :: MonadStore StorePath dummy = do let Right n = makeStorePathName "dummy"- res <- addToStore @'SHA256 n "dummy" False (pure True) False+ res <- addToStore @SHA256 n "dummy" False (pure True) False pure res invalidPath :: StorePath invalidPath = let Right n = makeStorePathName "invalid"- in StorePath (hash "invalid") n "no_such_root"+ in StorePath (mkStorePathHashPart "invalid") n "no_such_root" withBuilder :: (StorePath -> MonadStore a) -> MonadStore a withBuilder action = do@@ -259,7 +260,7 @@ itRights "adds file to store" $ do fp <- liftIO $ writeSystemTempFile "addition" "lal" let Right n = makeStorePathName "tmp-addition"- res <- addToStore @'SHA256 n fp False (pure True) False+ res <- addToStore @SHA256 n fp False (pure True) False liftIO $ print res context "with dummy" $ do