mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-10-05 13:47:47 +03:00
core: makeStorePathName -> mkStorePathName
This commit is contained in:
parent
569e68fad5
commit
06935815c6
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 =
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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']
|
||||
|
Loading…
Reference in New Issue
Block a user