@@ -53,7 +53,7 @@ import System.Nix.Realisation (BuildTraceKey(..), Realisation, RealisationWithId
5353import System.Nix.Realisation qualified
5454import System.Nix.Signature (Signature )
5555import System.Nix.Signature qualified
56- import System.Nix.StorePath (StorePath , StorePathName , StorePathHashPart , storePathHash , storePathName , mkStorePathName , unStorePathName , parseBasePathFromText )
56+ import System.Nix.StorePath (StorePath , StorePathName , StorePathHashPart , mkStorePathName , unStorePathName , parseBasePathFromText )
5757import System.Nix.StorePath qualified
5858
5959instance ToJSON StorePathName where
@@ -80,19 +80,8 @@ instance FromJSON StorePathHashPart where
8080 )
8181
8282instance ToJSON StorePath where
83- toJSON sp =
84- toJSON $ Data.Text. concat
85- [ System.Nix.StorePath. storePathHashPartToText (storePathHash sp)
86- , " -"
87- , System.Nix.StorePath. unStorePathName (storePathName sp)
88- ]
89-
90- toEncoding sp =
91- toEncoding $ Data.Text. concat
92- [ System.Nix.StorePath. storePathHashPartToText (storePathHash sp)
93- , " -"
94- , System.Nix.StorePath. unStorePathName (storePathName sp)
95- ]
83+ toJSON = toJSON . System.Nix.StorePath. storePathBaseToText
84+ toEncoding = toEncoding . System.Nix.StorePath. storePathBaseToText
9685
9786instance FromJSON StorePath where
9887 parseJSON =
@@ -104,12 +93,7 @@ instance FromJSON StorePath where
10493 )
10594
10695instance ToJSONKey StorePath where
107- toJSONKey = Data.Aeson.Types. toJSONKeyText $ \ sp ->
108- Data.Text. concat
109- [ System.Nix.StorePath. storePathHashPartToText (storePathHash sp)
110- , " -"
111- , System.Nix.StorePath. unStorePathName (storePathName sp)
112- ]
96+ toJSONKey = Data.Aeson.Types. toJSONKeyText System.Nix.StorePath. storePathBaseToText
11397
11498instance FromJSONKey StorePath where
11599 fromJSONKey = FromJSONKeyTextParser $
@@ -332,33 +316,19 @@ instance FromJSON SingleDerivedPath where
332316instance ToJSON DerivedPath where
333317 toJSON (DerivedPath_Opaque path) = toJSON path
334318 toJSON (DerivedPath_Built drvPath outputs) =
335- case outputs of
336- OutputsSpec_Names names | Data.Set. size names == 1 ->
337- object
338- [ " drvPath" .= toJSON drvPath
339- , " output" .= Data.Set. elemAt 0 names
340- ]
341- _ ->
342- object
343- [ " drvPath" .= toJSON drvPath
344- , " outputs" .= outputs
345- ]
319+ object
320+ [ " drvPath" .= toJSON drvPath
321+ , " outputs" .= outputs
322+ ]
346323
347324instance FromJSON DerivedPath where
348325 parseJSON v = parseOpaque v <|> parseBuilt v
349326 where
350327 parseOpaque = fmap DerivedPath_Opaque . parseJSON
351- parseBuilt = withObject " DerivedPath_Built" $ \ obj -> do
352- drvPath <- obj .: " drvPath"
353- -- Try single output first, then multiple outputs
354- mOutput <- obj .:? " output"
355- mOutputs <- obj .:? " outputs"
356- case (mOutput, mOutputs) of
357- (Just output, Nothing ) ->
358- pure $ DerivedPath_Built drvPath (OutputsSpec_Names (Data.Set. singleton output))
359- (Nothing , Just outputs) ->
360- pure $ DerivedPath_Built drvPath outputs
361- _ -> fail " Expected either 'output' or 'outputs' field"
328+ parseBuilt = withObject " DerivedPath_Built" $ \ obj ->
329+ DerivedPath_Built
330+ <$> obj .: " drvPath"
331+ <*> obj .: " outputs"
362332
363333data LowerLeading
364334instance StringModifier LowerLeading where
0 commit comments