@@ -20,7 +20,7 @@ module NixTree.StorePath
2020 )
2121where
2222
23- import Data.Aeson (FromJSON (.. ), Value (.. ), decode , (.: ) )
23+ import Data.Aeson (FromJSON (.. ), Value (.. ), decode , eitherDecode , (.!=) , (.:) , (.:? ) )
2424import qualified Data.Aeson.Key as K
2525import qualified Data.Aeson.KeyMap as KM
2626import Data.Aeson.Types (Parser )
@@ -163,7 +163,7 @@ data PathInfoOptions = PathInfoOptions
163163getPathInfo :: NixStore -> NixVersion -> PathInfoOptions -> NonEmpty Installable -> IO (NonEmpty (StorePath s (StoreName s ) () ))
164164getPathInfo nixStore nixVersion options names = do
165165 infos <-
166- decode @ NixPathOutput
166+ eitherDecode @ NixPathOutput
167167 <$> readProcessStdout_
168168 ( proc
169169 " nix"
@@ -183,7 +183,7 @@ getPathInfo nixStore nixVersion options names = do
183183 ++ map (toString . installableToText) (toList names)
184184 )
185185 )
186- >>= maybe ( fail " Failed parsing nix path-info output. " ) return
186+ >>= either ( \ e -> fail $ " Failed parsing nix path-info output: " ++ show e ) return
187187 >>= mapM assertValidInfo . npoResults
188188 >>= maybe (fail " invariant violation: getPathInfo returned []" ) return . nonEmpty
189189
@@ -405,7 +405,7 @@ parse2_18 (Object obj) =
405405 <$> obj .: " path"
406406 <*> obj .: " narSize"
407407 <*> obj .: " references"
408- <*> obj .: " signatures"
408+ <*> ( obj .:? " signatures" .!= [] )
409409 )
410410 )
411411 <|> ( do
@@ -423,7 +423,7 @@ parse2_19 (path, Object obj) =
423423 path
424424 <$> obj .: " narSize"
425425 <*> obj .: " references"
426- <*> obj .: " signatures"
426+ <*> ( obj .:? " signatures" .!= [] )
427427 )
428428parse2_19 (path, Null ) = return $ NixPathInfoInvalid path
429429parse2_19 (_, _) = fail " Expecting an object or null"
0 commit comments