| License | GPL-2.0-or-later |
|---|---|
| Safe Haskell | None |
| Language | Haskell2010 |
Cabal.Plan
Description
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
- 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.
Constructors
| PlanJson | |
Fields
| |
Represents a build-plan unit uniquely identified by its UnitId
Constructors
| Unit | |
Fields
| |
Component name inside a build-plan unit
A similiar type exists in Cabal codebase, see
Distribution.Simple.LocalBuildInfo.ComponentName
Constructors
| CompNameLib | |
| CompNameSubLib !Text | |
| CompNameFLib !Text | Since: 0.3.0.0 |
| CompNameExe !Text | |
| CompNameTest !Text | |
| CompNameBench !Text | |
| CompNameSetup |
Instances
| Eq CompName Source # | |
| Ord CompName Source # | |
Defined in Cabal.Plan | |
| Show CompName Source # | |
| ToJSON CompName Source # | |
Defined in Cabal.Plan | |
| ToJSONKey CompName Source # | |
Defined in Cabal.Plan | |
| FromJSON CompName Source # | |
| FromJSONKey CompName Source # | |
Defined in Cabal.Plan Methods | |
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 component-specific information inside a Unit
Constructors
| CompInfo | |
Describes kind of build unit and its provenance
Constructors
| 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
Instances
| Eq FlagName Source # | |
| Ord FlagName Source # | |
Defined in Cabal.Plan | |
| Show FlagName Source # | |
| ToJSON FlagName Source # | |
Defined in Cabal.Plan | |
| ToJSONKey FlagName Source # | |
Defined in Cabal.Plan | |
| FromJSON FlagName Source # | |
| FromJSONKey FlagName Source # | |
Defined in Cabal.Plan Methods | |
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
Constructors
| LocalUnpackedPackage !FilePath | |
| LocalTarballPackage !FilePath | |
| RemoteTarballPackage !URI | |
| RepoTarballPackage !Repo | |
| RemoteSourceRepoPackage !SourceRepo |
Equivalent to Cabal's Distribution.Types.SourceRepo
Since: 0.5.0.0
Constructors
| RepoLocal !FilePath | |
| RepoRemote !URI | |
| RepoSecure !URI |
data SourceRepo Source #
Equivalent to Cabal's Distribution.Client.Types.Repo
Since: 0.5.0.0
Constructors
| SourceRepo | |
Instances
| Eq SourceRepo Source # | |
Defined in Cabal.Plan | |
| Ord SourceRepo Source # | |
Defined in Cabal.Plan Methods 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 Methods showsPrec :: Int -> SourceRepo -> ShowS # show :: SourceRepo -> String # showList :: [SourceRepo] -> ShowS # | |
| FromJSON SourceRepo Source # | |
Defined in Cabal.Plan | |
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.
Constructors
| 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. |
Instances
| Eq SearchPlanJson Source # | |
Defined in Cabal.Plan Methods (==) :: SearchPlanJson -> SearchPlanJson -> Bool # (/=) :: SearchPlanJson -> SearchPlanJson -> Bool # | |
| Read SearchPlanJson Source # | |
Defined in Cabal.Plan Methods readsPrec :: Int -> ReadS SearchPlanJson # readList :: ReadS [SearchPlanJson] # | |
| Show SearchPlanJson Source # | |
Defined in Cabal.Plan Methods showsPrec :: Int -> SearchPlanJson -> ShowS # show :: SearchPlanJson -> String # showList :: [SearchPlanJson] -> ShowS # | |
findAndDecodePlanJson :: SearchPlanJson -> IO PlanJson Source #
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.
The folder assumed to be the project-root is returned as well.
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.
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.