haskell-nix / hnix-store

Haskell implementation of the Nix store
Apache License 2.0
86 stars 23 forks source link

remote: fix queryPathInfoUncached missing content address decoding #244

Closed squalus closed 10 months ago

squalus commented 10 months ago

queryPathInfoUncached fails with a "not enough input" message when decoding Metadata that is missing a content address.

nix-daemon encodes a missing content address as an empty string: https://github.com/NixOS/nix/blob/a6b315ae8/src/libstore/content-address.cc#L139

Change the decoding to return Nothing if the caString is empty.

I manually tested this with the following program:

{-# LANGUAGE OverloadedStrings #-}

module Main

where

import System.Nix.Store.Remote
import System.Nix.StorePath
import Control.Monad (void)
import Control.Monad.IO.Class (liftIO)
import Data.Default.Class

main :: IO()
main = do
  void $ runStore $ do
    let Right sp = parsePath def "/nix/store/sbldylj3clbkc0aqvjjzfa6slp4zdvlj-hello-2.12.1"
    q <- queryPathInfoUncached sp
    liftIO $ print q

The store path came from nix build nixpkgs#hello. Tested with nix 2.13.6.

sorki commented 10 months ago

Also done in daemon-server-side https://github.com/haskell-nix/hnix-store/pull/243#issuecomment-1822150182

May I ask you to take a look at #246 and #240? That would help me a lot and I'll deal with the -remote integration part meanwhile so you don't have to duplicate the work/fixes done there.

sorki commented 10 months ago

Or any of the recent issues marked as good first issue, which I won't do right now so I can focus on unblocking -remote.