Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype StoreDir = StoreDir {
- unStoreDir :: RawFilePath
- class HasStoreDir r where
- hasStoreDir :: r -> StoreDir
- data StorePath
- storePathHash :: StorePath -> StorePathHashPart
- storePathName :: StorePath -> StorePathName
- data StorePathName
- unStorePathName :: StorePathName -> Text
- data StorePathHashPart
- mkStorePathHashPart :: forall hashAlgo. HashAlgorithm hashAlgo => ByteString -> StorePathHashPart
- unStorePathHashPart :: StorePathHashPart -> ByteString
- data InvalidNameError
- mkStorePathName :: Text -> Either InvalidNameError StorePathName
- parseNameText :: Text -> Either InvalidNameError Text
- data InvalidPathError
- storePathToFilePath :: StoreDir -> StorePath -> FilePath
- storePathToRawFilePath :: StoreDir -> StorePath -> RawFilePath
- storePathToText :: StoreDir -> StorePath -> Text
- storePathToNarInfo :: StorePath -> ByteString
- storePathHashPartToText :: StorePathHashPart -> Text
- parsePath :: StoreDir -> ByteString -> Either InvalidPathError StorePath
- parsePathFromText :: StoreDir -> Text -> Either InvalidPathError StorePath
- pathParser :: StoreDir -> Parser StorePath
- unsafeMakeStorePath :: StorePathHashPart -> StorePathName -> StorePath
- unsafeMakeStorePathHashPart :: ByteString -> StorePathHashPart
Basic store path types
The path to the store dir
Many operations need to be parameterized with this, since store paths do not know their own store dir by design.
StoreDir | |
|
Instances
class HasStoreDir r where Source #
hasStoreDir :: r -> StoreDir Source #
A path in a Nix store.
From the Nix thesis: A store path is the full path of a store object. It has the following anatomy: storeDir/hashPart-name.
The store directory is *not* included, and must be known from the context. This matches modern C++ Nix, and also represents the fact that store paths for different store directories cannot be mixed.
Instances
Generic StorePath Source # | |
Show StorePath Source # | |
Eq StorePath Source # | |
Ord StorePath Source # | |
Defined in System.Nix.StorePath | |
Hashable StorePath Source # | |
Defined in System.Nix.StorePath | |
type Rep StorePath Source # | |
Defined in System.Nix.StorePath type Rep StorePath = D1 ('MetaData "StorePath" "System.Nix.StorePath" "hnix-store-core-0.8.0.0-2YQUX8JlMxk93e1fw1Y66G" 'False) (C1 ('MetaCons "StorePath" 'PrefixI 'True) (S1 ('MetaSel ('Just "storePathHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StorePathHashPart) :*: S1 ('MetaSel ('Just "storePathName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StorePathName))) |
storePathHash :: StorePath -> StorePathHashPart Source #
The 160-bit hash digest reflecting the "address" of the name. Currently, this is a truncated SHA256 hash.
storePathName :: StorePath -> StorePathName Source #
The (typically human readable) name of the path. For packages this is typically the package name and version (e.g. hello-1.2.3).
data StorePathName Source #
The name portion of a Nix path.
unStorePathName
must only contain a-zA-Z0-9+._?=-, can't start
with a -, and must have at least one character (i.e. it must match
storePathNameRegex
).
Instances
unStorePathName :: StorePathName -> Text Source #
Extract the contents of the name.
data StorePathHashPart Source #
The hash algorithm used for store path hashes.
Instances
mkStorePathHashPart :: forall hashAlgo. HashAlgorithm hashAlgo => ByteString -> StorePathHashPart Source #
Make StorePathHashPart
from ByteString
(hash part of the StorePath
)
using specific HashAlgorithm
unStorePathHashPart :: StorePathHashPart -> ByteString Source #
Extract the contents of the hash.
Manipulating StorePathName
data InvalidNameError Source #
Reason why a path name or output name is not valid
Instances
mkStorePathName :: Text -> Either InvalidNameError StorePathName Source #
Make StorePathName
from Text
(name part of the StorePath
)
or fail with InvalidNameError
if it isn't valid
parseNameText :: Text -> Either InvalidNameError Text Source #
Parse name (either StorePathName
or OutputName
)
Reason why a path is not valid
data InvalidPathError Source #
Reason why a path is not valid
Instances
Rendering out StorePath
s
storePathToRawFilePath :: StoreDir -> StorePath -> RawFilePath Source #
Render a StorePath
as a RawFilePath
.
storePathToNarInfo :: StorePath -> ByteString Source #
Build narinfo
suffix from StorePath
which
can be used to query binary caches.
storePathHashPartToText :: StorePathHashPart -> Text Source #
Render a StorePathHashPart
as a Text
.
This is used by remote store / database
via queryPathFromHashPart
Parsing StorePath
s
:: StoreDir | expected |
-> ByteString | |
-> Either InvalidPathError StorePath |
Parse StorePath
from ByteString
, checking
that store directory matches expectedRoot
.
:: StoreDir | expected |
-> Text | |
-> Either InvalidPathError StorePath |
Utilities for tests
unsafeMakeStorePath :: StorePathHashPart -> StorePathName -> StorePath Source #
Paths rarely need to be constructed directly.
Prefer parsePath
or parsePathFromText
unsafeMakeStorePathHashPart :: ByteString -> StorePathHashPart Source #
Path hash parts rarely need to be constructed directly.
Prefer mkStorePathHashPart
Used by remote store in wire protocol