Skip to content

Commit 555e2b7

Browse files
committed
remote: fix queryPathInfoUncached narHash decoding
nix-daemon encodes the narHash as Base16, not NixBase32: https://github.com/NixOS/nix/blob/a6b315ae/src/libstore/worker-protocol.cc#L180 Change the narHash decoding step to use Base16. Add a test that fails on the previous code with the following error: uncaught exception: ErrorCall Invalid NixBase32 string CallStack (from HasCallStack): Tested with nix 2.13.6.
1 parent f1741e8 commit 555e2b7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

hnix-store-remote/src/System/Nix/Store/Remote.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import System.Nix.Build ( BuildMode
4646
, BuildResult
4747
)
4848
import System.Nix.Hash ( NamedAlgo(..)
49-
, BaseEncoding(NixBase32)
49+
, BaseEncoding(Base16)
5050
, decodeDigestWith
5151
)
5252
import System.Nix.StorePath ( StorePath
@@ -235,7 +235,7 @@ queryPathInfoUncached path = do
235235
let
236236
narHash =
237237
case
238-
decodeDigestWith @SHA256 NixBase32 narHashText
238+
decodeDigestWith @SHA256 Base16 narHashText
239239
of
240240
Left e -> error e
241241
Right d -> System.Nix.Hash.HashAlgo_SHA256 :=> d

hnix-store-remote/tests-io/NixDaemon.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import System.FilePath
3333

3434
import System.Nix.Build
3535
import System.Nix.StorePath
36+
import System.Nix.StorePath.Metadata
3637
import System.Nix.Store.Remote
3738
import System.Nix.Store.Remote.Protocol
3839

@@ -217,7 +218,9 @@ spec_protocol = Hspec.around withNixDaemon $
217218
queryAllValidPaths `shouldReturn` HS.fromList [path]
218219

219220
context "queryPathInfoUncached" $
220-
itRights "queries path info" $ withPath queryPathInfoUncached
221+
itRights "queries path info" $ withPath $ \path -> do
222+
meta <- queryPathInfoUncached path
223+
references meta `shouldSatisfy` HS.null
221224

222225
context "ensurePath" $
223226
itRights "simple ensure" $ withPath ensurePath

0 commit comments

Comments
 (0)