-
Notifications
You must be signed in to change notification settings - Fork 245
One IFD for all project-related information? #1616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
See also #1370 (comment) |
Playing with cabal-install I managed to put togheter something like this. It should do most of what you want @michaelpj {- cabal:
build-depends: base ^>= 4.14
, bytestring
, directory
, filepath
, Cabal >=3.8 && <3.9
, cabal-install >=3.8 && <3.9
, pretty-simple
-}
module Main where
import Distribution.Client.DistDirLayout
import Distribution.Client.HttpUtils
import Distribution.Client.InstallPlan
import Distribution.Client.ProjectPlanOutput (writePlanExternalRepresentation)
import Distribution.Client.ProjectPlanning
import Distribution.Verbosity
import System.Environment
import Text.Pretty.Simple (pPrint)
main :: IO ()
main = do
[path] <- getArgs
let verbosity = verbose
let distDirLayout = defaultDistDirLayout (ProjectRootImplicit path) Nothing
httpTransport <- configureTransport verbosity mempty Nothing
(projectConfig, localPackages) <-
rebuildProjectConfig
verbosity
httpTransport
distDirLayout
mempty
putStrLn "-- projectConfig --"
pPrint projectConfig
putStrLn "-- localPackages --"
pPrint localPackages
let cabalDirLayout = defaultCabalDirLayout "/tmp/cabal-dir"
-- Two variants of the install plan are returned: with and without
-- packages from the store. That is, the "improved" plan where source
-- packages are replaced by pre-existing installed packages from the
-- store (when their ids match), and also the original elaborated plan
-- which uses primarily source packages.
(improvedPlan, elaboratedPlan, esc, tis, at) <- rebuildInstallPlan verbosity distDirLayout cabalDirLayout projectConfig localPackages
putStrLn $ unlines ["-- imporovedPlan -- ", showInstallPlan improvedPlan]
putStrLn $ unlines ["-- elaboratedPlan --", showInstallPlan elaboratedPlan]
putStrLn "-- elaborated shared config --"
pPrint esc
putStrLn "-- total index state --"
pPrint tis
putStrLn "-- active repos --"
pPrint at
-- writes plan.json in distProjectCacheFile distDirLayout
writePlanExternalRepresentation distDirLayout elaboratedPlan esc |
Is this issue something we want to implement in nix-tools? |
Yes, it would need to be synchronized across the two: |
Something similar is in progress at #1775 |
This idea was partially implemented in #1775 and this is the direction things are going. |
From discussion with @andreabedini.
At the moment we do a bunch of parsing of the
cabal.project
in Nix. This avoids us from having to do more IFD. But we have to do at least one IFD already to get theplan.json
. So we could have ananalyze-project
derivation that gives us theplan.json
but also the index-state, repository stanzas etc. That would let us write the logic in Haskell, which would be nicer and easier to test (and could maybe even use the cabal parser).cc @hamishmack
The text was updated successfully, but these errors were encountered: