License | GPL-2.0-or-later |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Utilities for reading cabal
's plan.json
file
plan.json
are generated when using cabal
Nix-style Local Builds.
Synopsis
- data PlanJson = PlanJson {
- pjCabalVersion :: !Ver
- pjCabalLibVersion :: !Ver
- pjCompilerId :: !PkgId
- pjArch :: !Text
- pjOs :: !Text
- pjUnits :: !(Map UnitId Unit)
- data Unit = Unit {}
- data CompName
- dispCompName :: CompName -> Text
- dispCompNameTarget :: PkgName -> CompName -> Text
- data CompInfo = CompInfo {}
- data UnitType
- newtype Ver = Ver [Int]
- dispVer :: Ver -> Text
- newtype PkgName = PkgName Text
- data PkgId = PkgId !PkgName !Ver
- dispPkgId :: PkgId -> Text
- newtype UnitId = UnitId Text
- newtype FlagName = FlagName Text
- data Sha256
- dispSha256 :: Sha256 -> Text
- parseSha256 :: Text -> Maybe Sha256
- sha256ToByteString :: Sha256 -> ByteString
- sha256FromByteString :: ByteString -> Maybe Sha256
- data PkgLoc
- data Repo
- = RepoLocal !FilePath
- | RepoRemote !URI
- | RepoSecure !URI
- data SourceRepo = SourceRepo {}
- newtype URI = URI Text
- data RepoType
- planJsonIdGraph :: PlanJson -> Map UnitId (Set UnitId)
- planJsonIdRoots :: PlanJson -> Set UnitId
- data SearchPlanJson
- findAndDecodePlanJson :: SearchPlanJson -> IO PlanJson
- findPlanJson :: SearchPlanJson -> IO FilePath
- findProjectRoot :: FilePath -> IO (Maybe FilePath)
- decodePlanJson :: FilePath -> IO PlanJson
Documentation
Represents the information contained in cabal's plan.json
file.
This comprises basic information describing the environment as well
as the install/build plan computed by cabal
.
PlanJson | |
|
Represents a build-plan unit uniquely identified by its UnitId
Unit | |
|
Component name inside a build-plan unit
A similiar type exists in Cabal
codebase, see
Distribution.Simple.LocalBuildInfo.ComponentName
CompNameLib | |
CompNameSubLib !Text | |
CompNameFLib !Text | Since: 0.3.0.0 |
CompNameExe !Text | |
CompNameTest !Text | |
CompNameBench !Text | |
CompNameSetup |
dispCompName :: CompName -> Text Source #
Pretty print CompName
in the same syntax that is used in
plan.json
. Note that this string can not be used as a target-selector on
the cabal command-line. See dispCompNameTarget
for a target-selector
compatible pretty printer.
dispCompNameTarget :: PkgName -> CompName -> Text Source #
Pretty print CompName
in cabal's target-selector syntax.
Since: 0.5.0.0
Describes kind of build unit and its provenance
UnitTypeBuiltin | Lives in global (non-nix-style) package db |
UnitTypeGlobal | Lives in Nix-store cache |
UnitTypeLocal | Local package |
UnitTypeInplace | Local in-place package |
Basic types
Equivalent to Cabal
's Distribution.Package.Version
Equivalent to Cabal
's Distribution.Package.PackageName
Equivalent to Cabal
's Distribution.Package.PackageIdentifier
Equivalent to Cabal
's Distribution.Package.UnitId
Equivalent to Cabal
's Distribution.PackageDescription.FlagName
Since: 0.3.0.0
SHA-256
SHA-256 hash
sha256ToByteString :: Sha256 -> ByteString Source #
Export the Sha256
digest to a 32-byte ByteString
.
Since: 0.3.0.0
sha256FromByteString :: ByteString -> Maybe Sha256 Source #
Import the Sha256
digest from a 32-byte ByteString
.
Returns Nothing
if input ByteString
has incorrect length.
Since: 0.3.0.0
PkgLoc
Equivalent to Cabal
's Distribution.Client.Types.PackageLocation
Since: 0.5.0.0
LocalUnpackedPackage !FilePath | |
LocalTarballPackage !FilePath | |
RemoteTarballPackage !URI | |
RepoTarballPackage !Repo | |
RemoteSourceRepoPackage !SourceRepo |
Equivalent to Cabal
's Distribution.Types.SourceRepo
Since: 0.5.0.0
data SourceRepo Source #
Equivalent to Cabal
's Distribution.Client.Types.Repo
Since: 0.5.0.0
Instances
Eq SourceRepo Source # | |
Defined in Cabal.Plan (==) :: SourceRepo -> SourceRepo -> Bool # (/=) :: SourceRepo -> SourceRepo -> Bool # | |
Ord SourceRepo Source # | |
Defined in Cabal.Plan compare :: SourceRepo -> SourceRepo -> Ordering # (<) :: SourceRepo -> SourceRepo -> Bool # (<=) :: SourceRepo -> SourceRepo -> Bool # (>) :: SourceRepo -> SourceRepo -> Bool # (>=) :: SourceRepo -> SourceRepo -> Bool # max :: SourceRepo -> SourceRepo -> SourceRepo # min :: SourceRepo -> SourceRepo -> SourceRepo # | |
Show SourceRepo Source # | |
Defined in Cabal.Plan showsPrec :: Int -> SourceRepo -> ShowS # show :: SourceRepo -> String # showList :: [SourceRepo] -> ShowS # | |
FromJSON SourceRepo Source # | |
Defined in Cabal.Plan parseJSON :: Value -> Parser SourceRepo # parseJSONList :: Value -> Parser [SourceRepo] # |
Represents an URI (used e.g. by Repo
)
Since: 0.5.0.0
Equivalent to Cabal
's Distribution.Client.SourceRepo.RepoType
Since: 0.5.0.0
Utilities
planJsonIdRoots :: PlanJson -> Set UnitId Source #
Extract UnitId
root nodes from dependency graph computed by planJsonIdGraph
Convenience functions
data SearchPlanJson Source #
Where/how to search for the plan.json file.
ProjectRelativeToDir FilePath | Find the project root relative to specified directory and look for plan.json there. |
InBuildDir FilePath | Look for plan.json in specified build directory. |
ExactPath FilePath | Exact location of plan.json |
Instances
Eq SearchPlanJson Source # | |
Defined in Cabal.Plan (==) :: SearchPlanJson -> SearchPlanJson -> Bool # (/=) :: SearchPlanJson -> SearchPlanJson -> Bool # | |
Read SearchPlanJson Source # | |
Defined in Cabal.Plan readsPrec :: Int -> ReadS SearchPlanJson # readList :: ReadS [SearchPlanJson] # | |
Show SearchPlanJson Source # | |
Defined in Cabal.Plan showsPrec :: Int -> SearchPlanJson -> ShowS # show :: SearchPlanJson -> String # showList :: [SearchPlanJson] -> ShowS # |
findAndDecodePlanJson :: SearchPlanJson -> IO PlanJson Source #
Find and decode plan.json
.
See findPlanJson
and decodePlanJson
.
findPlanJson :: SearchPlanJson -> IO FilePath Source #
Find plan.json
.
When ProjectRelativeToDir
is passed locates the project root for cabal
project relative to specified directory.
plan.json
is located from either the optional build dir argument, or in
the default directory (dist-newstyle
) relative to the project root.
This function determines the project root in a slightly more liberal manner than cabal-install. If no cabal.project is found, cabal-install assumes an implicit cabal.project if the current directory contains any *.cabal files.
This function looks for any *.cabal files in directories above the current one and behaves as if there is an implicit cabal.project in that directory when looking for a plan.json.
Throws IO
exceptions on errors.
Since: 0.6.2.0
findProjectRoot :: FilePath -> IO (Maybe FilePath) Source #
Find project root relative to a directory, this emulates cabal's current heuristic, but is slightly more liberal. If no cabal.project is found, cabal-install looks for *.cabal files in the specified directory only. This function also considers *.cabal files in directories higher up in the hierarchy.