Merge pull request #190 from haskell-nix/release/remote-0.6

Release remote 0.6
This commit is contained in:
Richard Marko 2022-06-06 12:21:23 +02:00 committed by GitHub
commit 74f543f775
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 21 deletions

View File

@ -1,5 +1,12 @@
# Revision history for hnix-store-remote # Revision history for hnix-store-remote
## [0.6.0.0](https://github.com/haskell-nix/hnix-store/compare/0.5.0.0...0.6.0.0) 2021-06-06
* Breaking:
* [(link)](https://github.com/haskell-nix/hnix-store/pull/179) `System.Nix.Store.Remote`:
* `addToStore` no longer accepts `FilePath` as its second argument but uses
more generic `NarSource` [(NarSource PR)](https://github.com/haskell-nix/hnix-store/pull/177)
## [0.5.0.0](https://github.com/haskell-nix/hnix-store/compare/0.4.3.0...0.5.0.0) 2021-06-11 ## [0.5.0.0](https://github.com/haskell-nix/hnix-store/compare/0.4.3.0...0.5.0.0) 2021-06-11
* Breaking: * Breaking:

View File

@ -1,6 +1,6 @@
cabal-version: 2.2 cabal-version: 2.2
name: hnix-store-remote name: hnix-store-remote
version: 0.5.0.0 version: 0.6.0.0
synopsis: Remote hnix store synopsis: Remote hnix store
description: Implementation of the nix store using the daemon protocol. description: Implementation of the nix store using the daemon protocol.
homepage: https://github.com/haskell-nix/hnix-store homepage: https://github.com/haskell-nix/hnix-store
@ -52,7 +52,7 @@ library
, nix-derivation >= 1.1.1 && <2 , nix-derivation >= 1.1.1 && <2
, mtl , mtl
, unordered-containers , unordered-containers
, hnix-store-core >= 0.5 && <0.6 , hnix-store-core >= 0.6 && <0.7
mixins: mixins:
base hiding (Prelude) base hiding (Prelude)
, relude (Relude as Prelude) , relude (Relude as Prelude)
@ -114,10 +114,8 @@ test-suite hnix-store-remote-tests
, tasty-quickcheck , tasty-quickcheck
, linux-namespaces , linux-namespaces
, temporary , temporary
, text
, unix , unix
, unordered-containers , unordered-containers
, vector
mixins: mixins:
base hiding (Prelude) base hiding (Prelude)
, relude (Relude as Prelude) , relude (Relude as Prelude)

View File

@ -4,6 +4,8 @@
{-# language ScopedTypeVariables #-} {-# language ScopedTypeVariables #-}
{-# language DataKinds #-} {-# language DataKinds #-}
{-# language RecordWildCards #-} {-# language RecordWildCards #-}
{-# language LiberalTypeSynonyms #-}
module System.Nix.Store.Remote module System.Nix.Store.Remote
( addToStore ( addToStore
, addTextToStore , addTextToStore
@ -59,7 +61,6 @@ import qualified Data.Binary.Put
import qualified Data.Map.Strict import qualified Data.Map.Strict
import qualified Data.Set import qualified Data.Set
import qualified System.Nix.Nar
import qualified System.Nix.StorePath import qualified System.Nix.StorePath
import qualified System.Nix.Store.Remote.Parsers import qualified System.Nix.Store.Remote.Parsers
@ -68,35 +69,29 @@ import System.Nix.Store.Remote.Types
import System.Nix.Store.Remote.Protocol import System.Nix.Store.Remote.Protocol
import System.Nix.Store.Remote.Util import System.Nix.Store.Remote.Util
import Crypto.Hash ( SHA256 ) import Crypto.Hash ( SHA256 )
import System.Nix.Nar ( NarSource )
type RepairFlag = Bool type RepairFlag = Bool
type CheckFlag = Bool type CheckFlag = Bool
type SubstituteFlag = Bool type SubstituteFlag = Bool
-- | Pack `FilePath` as `Nar` and add it to the store. -- | Pack `Nar` and add it to the store.
addToStore addToStore
:: forall a :: forall a
. NamedAlgo a . (NamedAlgo a)
=> StorePathName -- ^ Name part of the newly created `StorePath` => StorePathName -- ^ Name part of the newly created `StorePath`
-> FilePath -- ^ Local `FilePath` to add -> NarSource MonadStore -- ^ provide nar stream
-> Bool -- ^ Add target directory recursively -> Bool -- ^ Add target directory recursively
-> (FilePath -> Bool) -- ^ Path filter function
-> RepairFlag -- ^ Only used by local store backend -> RepairFlag -- ^ Only used by local store backend
-> MonadStore StorePath -> MonadStore StorePath
addToStore name pth recursive _pathFilter _repair = do addToStore name source recursive _repair = do
runOpArgsIO AddToStore $ \yield -> do runOpArgsIO AddToStore $ \yield -> do
yield $ toStrict $ Data.Binary.Put.runPut $ do yield $ toStrict $ Data.Binary.Put.runPut $ do
putText $ System.Nix.StorePath.unStorePathName name putText $ System.Nix.StorePath.unStorePathName name
putBool $ not $ System.Nix.Hash.algoName @a == "sha256" && recursive putBool $ not $ System.Nix.Hash.algoName @a == "sha256" && recursive
putBool recursive putBool recursive
putText $ System.Nix.Hash.algoName @a putText $ System.Nix.Hash.algoName @a
source yield
System.Nix.Nar.streamNarIO yield System.Nix.Nar.narEffectsIO pth
sockGetPath sockGetPath
-- | Add text to store. -- | Add text to store.

View File

@ -27,8 +27,8 @@ import System.Nix.StorePath
import System.Nix.Store.Remote import System.Nix.Store.Remote
import System.Nix.Store.Remote.Protocol import System.Nix.Store.Remote.Protocol
import Crypto.Hash ( SHA256 import Crypto.Hash ( SHA256 )
) import System.Nix.Nar ( dumpPath )
createProcessEnv :: FilePath -> String -> [String] -> IO P.ProcessHandle createProcessEnv :: FilePath -> String -> [String] -> IO P.ProcessHandle
createProcessEnv fp proc args = do createProcessEnv fp proc args = do
@ -159,7 +159,7 @@ withPath action = do
dummy :: MonadStore StorePath dummy :: MonadStore StorePath
dummy = do dummy = do
let Right n = makeStorePathName "dummy" let Right n = makeStorePathName "dummy"
addToStore @SHA256 n "dummy" False (pure True) False addToStore @SHA256 n (dumpPath "dummy") False False
invalidPath :: StorePath invalidPath :: StorePath
invalidPath = invalidPath =
@ -250,7 +250,7 @@ spec_protocol = Hspec.around withNixDaemon $
itRights "adds file to store" $ do itRights "adds file to store" $ do
fp <- liftIO $ writeSystemTempFile "addition" "lal" fp <- liftIO $ writeSystemTempFile "addition" "lal"
let Right n = makeStorePathName "tmp-addition" let Right n = makeStorePathName "tmp-addition"
res <- addToStore @SHA256 n fp False (pure True) False res <- addToStore @SHA256 n (dumpPath fp) False False
liftIO $ print res liftIO $ print res
context "with dummy" $ do context "with dummy" $ do