@@ -33,9 +33,10 @@ import Data.Hashable (Hashable(..))
3333import Data.HashSet (HashSet )
3434import Data.Proxy (Proxy (.. ))
3535
36- import Data.Attoparsec.ByteString.Char8 (Parser , (<?>) )
37- import qualified Data.Attoparsec.ByteString.Char8 as P
38- import System.FilePath (splitFileName )
36+ import Data.Attoparsec.Text.Lazy (Parser , (<?>) )
37+
38+ import qualified Data.Attoparsec.Text.Lazy
39+ import qualified System.FilePath
3940
4041-- | A path in a Nix store.
4142--
@@ -162,6 +163,12 @@ storePathToFilePath
162163 -> FilePath
163164storePathToFilePath = BC. unpack . storePathToRawFilePath
164165
166+ -- | Render a 'StorePath' as a 'Text'.
167+ storePathToText
168+ :: StorePath
169+ -> Text
170+ storePathToText = T. pack . BC. unpack . storePathToRawFilePath
171+
165172-- | Build `narinfo` suffix from `StorePath` which
166173-- can be used to query binary caches.
167174storePathToNarInfo
@@ -180,7 +187,7 @@ parsePath
180187 -> Either String StorePath
181188parsePath expectedRoot x =
182189 let
183- (rootDir, fname) = splitFileName . BC. unpack $ x
190+ (rootDir, fname) = System.FilePath. splitFileName . BC. unpack $ x
184191 (digestPart, namePart) = T. breakOn " -" $ T. pack fname
185192 digest = decodeBase32 digestPart
186193 name = makeStorePathName . T. drop 1 $ namePart
@@ -195,28 +202,26 @@ parsePath expectedRoot x =
195202
196203pathParser :: FilePath -> Parser StorePath
197204pathParser expectedRoot = do
198- P. string (BC . pack expectedRoot)
205+ Data.Attoparsec.Text.Lazy. string (T . pack expectedRoot)
199206 <?> " Store root mismatch" -- e.g. /nix/store
200207
201- P . char ' /'
208+ Data.Attoparsec.Text.Lazy . char ' /'
202209 <?> " Expecting path separator"
203210
204- digest <- decodeBase32 . T. pack . BC. unpack
205- <$> P . takeWhile1 (\ c -> c `elem` digits32)
211+ digest <- decodeBase32
212+ <$> Data.Attoparsec.Text.Lazy . takeWhile1 (\ c -> c `elem` digits32)
206213 <?> " Invalid Base32 part"
207214
208- P . char ' -'
215+ Data.Attoparsec.Text.Lazy . char ' -'
209216 <?> " Expecting dash (path name separator)"
210217
211- c0 <- P . satisfy (\ c -> c /= ' .' && validStorePathNameChar c)
218+ c0 <- Data.Attoparsec.Text.Lazy . satisfy (\ c -> c /= ' .' && validStorePathNameChar c)
212219 <?> " Leading path name character is a dot or invalid character"
213220
214- rest <- P .takeWhile validStorePathNameChar
221+ rest <- Data.Attoparsec.Text.Lazy .takeWhile validStorePathNameChar
215222 <?> " Path name contains invalid character"
216223
217- let name = makeStorePathName
218- $ T. pack . BC. unpack
219- $ BC. cons c0 rest
224+ let name = makeStorePathName $ T. cons c0 rest
220225
221226 either fail return
222227 $ StorePath <$> digest <*> name <*> pure expectedRoot
0 commit comments