From 3e0ee222bae82174cd4da724eb0499fc37f743bd Mon Sep 17 00:00:00 2001 From: soulomoon Date: Wed, 25 May 2022 21:03:19 +0800 Subject: [PATCH 1/4] replace the filepath argument in addToStore with a more common type NarSource (The remote part) --- .../src/System/Nix/Store/Remote.hs | 21 +++++++------------ hnix-store-remote/tests/NixDaemon.hs | 8 +++---- 2 files changed, 12 insertions(+), 17 deletions(-) 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 From b43d6f598f470ff8b6d44f276bf53c7a9f13838c Mon Sep 17 00:00:00 2001 From: Richard Marko Date: Mon, 6 Jun 2022 10:59:07 +0200 Subject: [PATCH 2/4] remote: adapt bounds for core-0.6 --- hnix-store-remote/hnix-store-remote.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hnix-store-remote/hnix-store-remote.cabal b/hnix-store-remote/hnix-store-remote.cabal index ff39813..f4097fa 100644 --- a/hnix-store-remote/hnix-store-remote.cabal +++ b/hnix-store-remote/hnix-store-remote.cabal @@ -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) From de176877f982316b2fd10e248312f4fb61f27d63 Mon Sep 17 00:00:00 2001 From: Richard Marko Date: Mon, 6 Jun 2022 11:36:52 +0200 Subject: [PATCH 3/4] remote: drop unused deps in testsuite --- hnix-store-remote/hnix-store-remote.cabal | 2 -- 1 file changed, 2 deletions(-) diff --git a/hnix-store-remote/hnix-store-remote.cabal b/hnix-store-remote/hnix-store-remote.cabal index f4097fa..1541269 100644 --- a/hnix-store-remote/hnix-store-remote.cabal +++ b/hnix-store-remote/hnix-store-remote.cabal @@ -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) From 4f80b535f28e74bc7099cbb8c03319b6bfea5900 Mon Sep 17 00:00:00 2001 From: Richard Marko Date: Mon, 6 Jun 2022 11:26:09 +0200 Subject: [PATCH 4/4] Relase remote 0.6 --- hnix-store-remote/ChangeLog.md | 7 +++++++ hnix-store-remote/hnix-store-remote.cabal | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) 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 1541269..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