|
10 | 10 | module System.Nix.Store.Remote |
11 | 11 | ( |
12 | 12 | addToStore |
13 | | - , addToStoreNar |
14 | 13 | , addTextToStore |
15 | 14 | , addSignatures |
16 | 15 | , addIndirectRoot |
@@ -45,7 +44,6 @@ import Data.Text (Text) |
45 | 44 | import Nix.Derivation (Derivation) |
46 | 45 | import System.Nix.Build (BuildMode, BuildResult) |
47 | 46 | import System.Nix.Hash (Digest, NamedAlgo, ValidAlgo, SomeNamedDigest(..)) |
48 | | -import System.Nix.Nar (Nar) |
49 | 47 | import System.Nix.StorePath (StorePath, StorePathName, StorePathSet, StorePathHashAlgo) |
50 | 48 | import System.Nix.StorePathMetadata (StorePathMetadata(..), StorePathTrust(..)) |
51 | 49 |
|
@@ -83,74 +81,22 @@ addToStore :: forall a. (ValidAlgo a, NamedAlgo a) |
83 | 81 | -> MonadStore StorePath |
84 | 82 | addToStore name pth recursive _pathFilter _repair = do |
85 | 83 |
|
86 | | - nar :: ByteString <- Control.Monad.IO.Class.liftIO |
87 | | - $ Data.Binary.Put.runPut . System.Nix.Nar.putNar |
88 | | - <$> System.Nix.Nar.localPackNar System.Nix.Nar.narEffectsIO pth |
| 84 | + runOpArgsIO AddToStore $ \yield -> do |
| 85 | + yield $ Data.ByteString.Lazy.toStrict $ Data.Binary.Put.runPut $ do |
| 86 | + putText $ System.Nix.StorePath.unStorePathName name |
89 | 87 |
|
90 | | - runOpArgs AddToStore $ do |
91 | | - putText $ System.Nix.StorePath.unStorePathName name |
| 88 | + putBool |
| 89 | + $ not |
| 90 | + $ System.Nix.Hash.algoName @a == "sha256" && recursive |
92 | 91 |
|
93 | | - putBool |
94 | | - $ not |
95 | | - $ System.Nix.Hash.algoName @a == "sha256" && recursive |
| 92 | + putBool recursive |
96 | 93 |
|
97 | | - putBool recursive |
| 94 | + putText $ System.Nix.Hash.algoName @a |
98 | 95 |
|
99 | | - putText $ System.Nix.Hash.algoName @a |
100 | | - |
101 | | - Data.Binary.Put.putLazyByteString nar |
| 96 | + System.Nix.Nar.streamNarIO yield System.Nix.Nar.narEffectsIO pth |
102 | 97 |
|
103 | 98 | sockGetPath |
104 | 99 |
|
105 | | --- | Add `Nar` to the store. |
106 | | --- |
107 | | -addToStoreNar :: StorePathMetadata |
108 | | - -> Nar |
109 | | - -> RepairFlag |
110 | | - -> CheckSigsFlag |
111 | | - -> MonadStore () |
112 | | -addToStoreNar StorePathMetadata{..} nar repair checkSigs = do |
113 | | - -- after the command, protocol asks for data via Read message |
114 | | - -- so we provide it here |
115 | | - let n = Data.Binary.Put.runPut $ System.Nix.Nar.putNar nar |
116 | | - setData n |
117 | | - |
118 | | - void $ runOpArgs AddToStoreNar $ do |
119 | | - putPath path |
120 | | - maybe (putText "") (putPath) deriverPath |
121 | | - let putNarHash :: SomeNamedDigest -> Data.Binary.Put.PutM () |
122 | | - putNarHash (SomeDigest hash) = putByteStringLen |
123 | | - $ Data.ByteString.Lazy.fromStrict |
124 | | - $ Data.Text.Encoding.encodeUtf8 |
125 | | - $ System.Nix.Hash.encodeBase32 hash |
126 | | - |
127 | | - putNarHash narHash |
128 | | - putPaths references |
129 | | - putTime registrationTime |
130 | | - |
131 | | - -- XXX: StorePathMetadata defines this as Maybe |
132 | | - -- `putInt 0` instead of error? |
133 | | - maybe (error "NO NAR BYTES") putInt narBytes |
134 | | - |
135 | | - putBool (trust == BuiltLocally) |
136 | | - |
137 | | - -- XXX: signatures need pubkey from config |
138 | | - putTexts [""] |
139 | | - |
140 | | - maybe |
141 | | - (putText "") |
142 | | - (putText |
143 | | - . Data.Text.Lazy.toStrict |
144 | | - . System.Nix.Store.Remote.Builders.buildContentAddressableAddress |
145 | | - -- this calls for changing the type of addToStoreNar |
146 | | - -- to forall a . (Valid/Named)Algo and a type app |
147 | | - @'System.Nix.Hash.SHA256 |
148 | | - ) |
149 | | - contentAddressableAddress |
150 | | - |
151 | | - putBool repair |
152 | | - putBool (not checkSigs) |
153 | | - |
154 | 100 | -- | Add text to store. |
155 | 101 | -- |
156 | 102 | -- Reference accepts repair but only uses it |
|
0 commit comments