Skip to content

Commit aad97d2

Browse files
committed
fixup! simple store path root, remote store rework
1 parent d99692c commit aad97d2

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

hnix-store-core/src/System/Nix/Internal/StorePath.hs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,28 @@ storePathToRawFilePath StorePath {..} = BS.concat
150150
hashPart = encodeUtf8 $ encodeBase32 storePathHash
151151
name = encodeUtf8 $ unStorePathName storePathName
152152

153-
storePathToNarinfo StorePath {..} = BS.concat
153+
-- | Render a 'StorePath' as a 'FilePath'.
154+
storePathToFilePath
155+
:: StorePath
156+
-> FilePath
157+
storePathToFilePath = BC.unpack . storePathToRawFilePath
158+
159+
-- | Build `narinfo` suffix from `StorePath` which
160+
-- can be used to query binary caches.
161+
storePathToNarInfo
162+
:: StorePath
163+
-> BC.ByteString
164+
storePathToNarInfo StorePath {..} = BS.concat
154165
[ encodeUtf8 $ encodeBase32 storePathHash
155166
, ".narinfo"
156167
]
157168

158169
-- | Parse `StorePath` from `BC.ByteString`, checking
159170
-- that store directory matches `expectedRoot`.
160-
parsePath :: FilePath -> BC.ByteString -> Either String StorePath
171+
parsePath
172+
:: FilePath
173+
-> BC.ByteString
174+
-> Either String StorePath
161175
parsePath expectedRoot x =
162176
let
163177
(rootDir, fname) = splitFileName . BC.unpack $ x

hnix-store-core/src/System/Nix/StorePath.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module System.Nix.StorePath
1515
, validStorePathName
1616
, -- * Rendering out 'StorePath's
1717
storePathToRawFilePath
18+
, storePathToFilePath
19+
, storePathToNarInfo
1820
, parsePath
1921
) where
2022

0 commit comments

Comments
 (0)