core: makeStorePathName -> mkStorePathName

This commit is contained in:
sorki 2023-12-04 20:18:19 +01:00
parent 569e68fad5
commit 06935815c6
7 changed files with 13 additions and 12 deletions

View File

@ -1,6 +1,7 @@
# Next
* Changes:
* `System.Nix.StorePath.makeStorePathName` renamed to `System.Nix.StorePath.mkStorePathName`
* `System.Nix.ReadOnlyStore` moved to `hnix-store-readonly` package
and renamed to `System.Nix.Store.ReadOnly` [#247](https://github.com/haskell-nix/hnix-store/pull/247)
* `System.Nix.Nar*` moved to `hnix-store-nar` package [#247](https://github.com/haskell-nix/hnix-store/pull/247)

View File

@ -47,7 +47,7 @@ parseOutputsSpec t
| t == "*" = Right OutputsSpec_All
| otherwise = do
names <- mapM
(convertError . System.Nix.StorePath.makeStorePathName)
(convertError . System.Nix.StorePath.mkStorePathName)
(Data.Text.splitOn "," t)
if null names
then Left ParseOutputsError_NoNames

View File

@ -18,7 +18,7 @@ module System.Nix.StorePath
, mkStorePathHashPart
, unStorePathHashPart
, -- * Manipulating 'StorePathName'
makeStorePathName
mkStorePathName
, validStorePathName
-- * Reason why a path is not valid
, InvalidPathError(..)
@ -130,8 +130,8 @@ data InvalidPathError =
-- | Make @StorePathName@ from @Text@ (name part of the @StorePath@)
-- or fail with @InvalidPathError@ if it isn't valid
makeStorePathName :: Text -> Either InvalidPathError StorePathName
makeStorePathName n =
mkStorePathName :: Text -> Either InvalidPathError StorePathName
mkStorePathName n =
if validStorePathName n
then pure $ StorePathName n
else Left $ reasonInvalid n
@ -224,7 +224,7 @@ parsePath' expectedRoot stringyPath =
HashDecodingFailure
StorePathHashPart
$ System.Nix.Base.decodeWith NixBase32 storeBasedHashPart
name = makeStorePathName . Data.Text.drop 1 $ namePart
name = mkStorePathName . Data.Text.drop 1 $ namePart
--rootDir' = dropTrailingPathSeparator rootDir
-- cannot use ^^ as it drops multiple slashes /a/b/// -> /a/b
rootDir' = init rootDir
@ -288,7 +288,7 @@ pathParser expectedRoot = do
validStorePathNameChar
<?> "Path name contains invalid character"
let name = makeStorePathName $ Data.Text.cons c0 rest
let name = mkStorePathName $ Data.Text.cons c0 rest
hashPart = Data.Bifunctor.bimap
HashDecodingFailure
StorePathHashPart

View File

@ -21,7 +21,7 @@ testDigest = Crypto.Hash.hash @ByteString "testDigest"
testName :: StorePathName
testName =
either undefined id
$ System.Nix.StorePath.makeStorePathName "testFixed"
$ System.Nix.StorePath.mkStorePathName "testFixed"
testPath :: StorePath
testPath =

View File

@ -494,7 +494,7 @@ storePathName :: NixSerializer r SError StorePathName
storePathName =
mapPrismSerializer
(Data.Bifunctor.first SError_Path
. System.Nix.StorePath.makeStorePathName)
. System.Nix.StorePath.mkStorePathName)
System.Nix.StorePath.unStorePathName
text

View File

@ -163,12 +163,12 @@ withPath action = do
-- | dummy path, adds <tmp>/dummy with "Hello World" contents
dummy :: MonadStore StorePath
dummy = do
let name = Data.Either.fromRight (error "impossible") $ makeStorePathName "dummy"
let name = Data.Either.fromRight (error "impossible") $ mkStorePathName "dummy"
addToStore @SHA256 name (dumpPath "dummy") FileIngestionMethod_Flat RepairMode_DontRepair
invalidPath :: StorePath
invalidPath =
let name = Data.Either.fromRight (error "impossible") $ makeStorePathName "invalid"
let name = Data.Either.fromRight (error "impossible") $ mkStorePathName "invalid"
in unsafeMakeStorePath (mkStorePathHashPart @SHA256 "invalid") name
withBuilder :: (StorePath -> MonadStore a) -> MonadStore a
@ -276,7 +276,7 @@ spec_protocol = Hspec.around withNixDaemon $
context "addToStore" $
itRights "adds file to store" $ do
fp <- liftIO $ writeSystemTempFile "addition" "lal"
let name = Data.Either.fromRight (error "impossible") $ makeStorePathName "tmp-addition"
let name = Data.Either.fromRight (error "impossible") $ mkStorePathName "tmp-addition"
res <- addToStore @SHA256 name (dumpPath fp) FileIngestionMethod_Flat RepairMode_DontRepair
liftIO $ print res

View File

@ -32,7 +32,7 @@ instance Arbitrary StorePath where
instance Arbitrary StorePathName where
arbitrary =
either undefined id
. System.Nix.StorePath.makeStorePathName
. System.Nix.StorePath.mkStorePathName
. Data.Text.pack <$> ((:) <$> s1 <*> listOf sn)
where
alphanum = ['a' .. 'z'] <> ['A' .. 'Z'] <> ['0' .. '9']