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
- 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
- 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
.
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: cabal-plan-0.3.0.0 |
CompNameExe !Text | |
CompNameTest !Text | |
CompNameBench !Text | |
CompNameSetup |
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: cabal-plan-0.3.0.0
SHA-256
SHA-256 hash
sha256ToByteString :: Sha256 -> ByteString Source #
Export the Sha256
digest to a 32-byte ByteString
.
Since: cabal-plan-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: cabal-plan-0.3.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. |
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 #
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.