Skip to content

Commit 13c0c42

Browse files
committed
feat: show cache signature(s)
1 parent 6cd7c6f commit 13c0c42

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/NixTree/App.hs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,22 @@ renderList highlightSort =
150150
StorePath
151151
{ spName,
152152
spPayload = PathStats {psTotalSize, psAddedSize},
153-
spRefs
153+
spRefs,
154+
spSignatures
154155
} ->
155156
let color =
156157
if null spRefs
157158
then B.withAttr attrTerminal
158159
else identity
159160
in color $
160161
B.hBox
161-
[ B.txt (storeNameToShortText spName)
162+
[
163+
if null spSignatures
164+
then
165+
B.txt " "
166+
else
167+
B.txt "",
168+
B.txt (storeNameToShortText spName)
162169
& underlineWhen SortOrderAlphabetical
163170
& B.padRight (B.Pad 1)
164171
& B.padRight B.Max,
@@ -375,7 +382,8 @@ renderInfoPane env =
375382
in B.vBox
376383
[ let (f, s) = storeNameToSplitShortText (spName selected)
377384
in B.txt f B.<+> underlineWhen SortOrderAlphabetical (B.txt s),
378-
[ B.txt $ "NAR Size: " <> prettySize (spSize selected),
385+
[ B.txt $ "Signatures: " <> if null (spSignatures selected) then "" else "",
386+
B.txt $ "NAR Size: " <> prettySize (spSize selected),
379387
underlineWhen SortOrderClosureSize . B.txt $ "Closure Size: " <> prettySize (psTotalSize $ spPayload selected),
380388
underlineWhen SortOrderAddedSize . B.txt $ "Added Size: " <> prettySize (psAddedSize $ spPayload selected)
381389
]

src/NixTree/StorePath.hs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ data StorePath s ref payload = StorePath
140140
{ spName :: StoreName s,
141141
spSize :: Int,
142142
spRefs :: [ref],
143-
spPayload :: payload
143+
spPayload :: payload,
144+
spSignatures :: [String]
144145
}
145146
deriving (Show, Eq, Ord, Functor, Generic)
146147

@@ -187,14 +188,15 @@ getPathInfo nixStore nixVersion options names = do
187188

188189
mapM infoToStorePath infos
189190
where
190-
infoToStorePath NixPathInfo {npiPath, npiNarSize, npiReferences} = do
191+
infoToStorePath NixPathInfo {npiPath, npiNarSize, npiReferences, npiSignatures} = do
191192
name <- mkStoreNameIO npiPath
192193
refs <- filter (/= name) <$> mapM mkStoreNameIO npiReferences
193194
return $
194195
StorePath
195196
{ spName = name,
196197
spRefs = refs,
197198
spSize = npiNarSize,
199+
spSignatures = npiSignatures,
198200
spPayload = ()
199201
}
200202
mkStoreNameIO p =
@@ -372,7 +374,8 @@ storeEnvToDot env =
372374
data NixPathInfo = NixPathInfo
373375
{ npiPath :: FilePath,
374376
npiNarSize :: Int,
375-
npiReferences :: [FilePath]
377+
npiReferences :: [FilePath],
378+
npiSignatures :: [String]
376379
}
377380

378381
data NixPathInfoResult
@@ -386,6 +389,7 @@ parse2_18 (Object obj) =
386389
<$> obj .: "path"
387390
<*> obj .: "narSize"
388391
<*> obj .: "references"
392+
<*> obj .: "signatures"
389393
)
390394
)
391395
<|> ( do
@@ -403,6 +407,7 @@ parse2_19 (path, Object obj) =
403407
path
404408
<$> obj .: "narSize"
405409
<*> obj .: "references"
410+
<*> obj .: "signatures"
406411
)
407412
parse2_19 (path, Null) = return $ NixPathInfoInvalid path
408413
parse2_19 (_, _) = fail "Expecting an object or null"

0 commit comments

Comments
 (0)