Skip to content

Commit

Permalink
Parse signatures earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
utdemir committed Jan 8, 2025
1 parent e75f74a commit e6a0456
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/NixTree/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,19 @@ renderInfoPane env =
in B.txt f B.<+> underlineWhen SortOrderAlphabetical (B.txt s),
[ B.txt $ "NAR Size: " <> prettySize (spSize selected),
underlineWhen SortOrderClosureSize . B.txt $ "Closure Size: " <> prettySize (psTotalSize $ spPayload selected),
underlineWhen SortOrderAddedSize . B.txt $ "Added Size: " <> prettySize (psAddedSize $ spPayload selected),
B.txt $
"Signatures: "
<> if null signatures
then ""
else (map (\s -> (fromMaybe "?" (viaNonEmpty head (T.splitOn ":" (T.pack s))))) signatures) & T.intercalate ", "
underlineWhen SortOrderAddedSize . B.txt $ "Added Size: " <> prettySize (psAddedSize $ spPayload selected)
]
& intersperse (B.txt " | ")
& B.hBox,
B.txt $
"Signatures: "
<> if null signatures
then ""
else
( signatures
& map npsKeyName
& T.intercalate ", "
),
B.txt $
if null immediateParents
then "Immediate Parents: -"
Expand Down
20 changes: 18 additions & 2 deletions src/NixTree/StorePath.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module NixTree.StorePath
storeNameToText,
storeNameToShortText,
storeNameToSplitShortText,
NixPathSignature (..),
StorePath (..),
Installable (..),
StoreEnv (..),
Expand Down Expand Up @@ -141,7 +142,7 @@ data StorePath s ref payload = StorePath
spSize :: Int,
spRefs :: [ref],
spPayload :: payload,
spSignatures :: [String]
spSignatures :: [NixPathSignature]
}
deriving (Show, Eq, Ord, Functor, Generic)

Expand Down Expand Up @@ -375,9 +376,24 @@ data NixPathInfo = NixPathInfo
{ npiPath :: FilePath,
npiNarSize :: Int,
npiReferences :: [FilePath],
npiSignatures :: [String]
npiSignatures :: [NixPathSignature]
}

data NixPathSignature = NixPathSignature
{ npsKeyName :: Text,
npsSignature :: Text
}
deriving (Show, Eq, Ord, NFData, Generic)

instance FromJSON NixPathSignature where
parseJSON (String t) =
case T.splitOn ":" t of
[key, sig]
| not (T.null key) && not (T.null sig) ->
Just $ NixPathSignature key sig
_ -> fail "Expecting a string in the form of 'key:sig'."
parseJSON _ = fail "Expecting a string."

data NixPathInfoResult
= NixPathInfoValid NixPathInfo
| NixPathInfoInvalid FilePath
Expand Down

0 comments on commit e6a0456

Please sign in to comment.