diff --git a/hnix-store-remote/ChangeLog.md b/hnix-store-remote/ChangeLog.md index 721e491..57cf931 100644 --- a/hnix-store-remote/ChangeLog.md +++ b/hnix-store-remote/ChangeLog.md @@ -1,5 +1,12 @@ # 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 * Breaking: diff --git a/hnix-store-remote/hnix-store-remote.cabal b/hnix-store-remote/hnix-store-remote.cabal index ff39813..0e67f43 100644 --- a/hnix-store-remote/hnix-store-remote.cabal +++ b/hnix-store-remote/hnix-store-remote.cabal @@ -1,6 +1,6 @@ cabal-version: 2.2 name: hnix-store-remote -version: 0.5.0.0 +version: 0.6.0.0 synopsis: Remote hnix store description: Implementation of the nix store using the daemon protocol. homepage: https://github.com/haskell-nix/hnix-store @@ -52,7 +52,7 @@ library , nix-derivation >= 1.1.1 && <2 , mtl , unordered-containers - , hnix-store-core >= 0.5 && <0.6 + , hnix-store-core >= 0.6 && <0.7 mixins: base hiding (Prelude) , relude (Relude as Prelude) @@ -114,10 +114,8 @@ test-suite hnix-store-remote-tests , tasty-quickcheck , linux-namespaces , temporary - , text , unix , unordered-containers - , vector mixins: base hiding (Prelude) , relude (Relude as Prelude) diff --git a/hnix-store-remote/src/System/Nix/Store/Remote.hs b/hnix-store-remote/src/System/Nix/Store/Remote.hs index 68b6cc2..1248dbd 100644 --- a/hnix-store-remote/src/System/Nix/Store/Remote.hs +++ b/hnix-store-remote/src/System/Nix/Store/Remote.hs @@ -4,6 +4,8 @@ {-# language ScopedTypeVariables #-} {-# language DataKinds #-} {-# language RecordWildCards #-} +{-# language LiberalTypeSynonyms #-} + module System.Nix.Store.Remote ( addToStore , addTextToStore @@ -59,7 +61,6 @@ import qualified Data.Binary.Put import qualified Data.Map.Strict import qualified Data.Set -import qualified System.Nix.Nar import qualified System.Nix.StorePath 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.Util import Crypto.Hash ( SHA256 ) +import System.Nix.Nar ( NarSource ) type RepairFlag = Bool type CheckFlag = Bool type SubstituteFlag = Bool --- | Pack `FilePath` as `Nar` and add it to the store. +-- | Pack `Nar` and add it to the store. addToStore :: forall a - . NamedAlgo a + . (NamedAlgo a) => StorePathName -- ^ Name part of the newly created `StorePath` - -> FilePath -- ^ Local `FilePath` to add + -> NarSource MonadStore -- ^ provide nar stream -> Bool -- ^ Add target directory recursively - -> (FilePath -> Bool) -- ^ Path filter function -> RepairFlag -- ^ Only used by local store backend -> MonadStore StorePath -addToStore name pth recursive _pathFilter _repair = do - +addToStore name source recursive _repair = do runOpArgsIO AddToStore $ \yield -> do yield $ toStrict $ Data.Binary.Put.runPut $ do putText $ System.Nix.StorePath.unStorePathName name - putBool $ not $ System.Nix.Hash.algoName @a == "sha256" && recursive - putBool recursive - putText $ System.Nix.Hash.algoName @a - - System.Nix.Nar.streamNarIO yield System.Nix.Nar.narEffectsIO pth - + source yield sockGetPath -- | Add text to store. diff --git a/hnix-store-remote/tests/NixDaemon.hs b/hnix-store-remote/tests/NixDaemon.hs index 3512094..8fff0b9 100644 --- a/hnix-store-remote/tests/NixDaemon.hs +++ b/hnix-store-remote/tests/NixDaemon.hs @@ -27,8 +27,8 @@ import System.Nix.StorePath import System.Nix.Store.Remote 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 fp proc args = do @@ -159,7 +159,7 @@ withPath action = do dummy :: MonadStore StorePath dummy = do let Right n = makeStorePathName "dummy" - addToStore @SHA256 n "dummy" False (pure True) False + addToStore @SHA256 n (dumpPath "dummy") False False invalidPath :: StorePath invalidPath = @@ -250,7 +250,7 @@ spec_protocol = Hspec.around withNixDaemon $ 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 (dumpPath fp) False False liftIO $ print res context "with dummy" $ do