@@ -89,7 +89,6 @@ import Distribution.Compiler
8989import Distribution.Package
9090 ( Package (.. )
9191 , UnitId
92- , installedUnitId
9392 , mkPackageName
9493 , packageName
9594 )
@@ -198,7 +197,9 @@ import System.FilePath
198197 , splitSearchPath
199198 , (</>)
200199 )
201- import Distribution.Solver.Types.Stage
200+ import Distribution.Solver.Types.Stage (Stage (.. ), Staged (.. ))
201+ import qualified Distribution.Compat.Graph as Graph
202+ import Distribution.Client.ProjectPlanning.Stage (WithStage (.. ))
202203
203204replCommand :: CommandUI (NixStyleFlags ReplFlags )
204205replCommand =
@@ -345,15 +346,16 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g
345346 -- especially in the no-project case.
346347 withInstallPlan (lessVerbose verbosity) baseCtx' $ \ elaboratedPlan sharedConfig -> do
347348 -- targets should be non-empty map, but there's no NonEmptyMap yet.
348- -- TODO: This only makes sense for the build stage
349- let Toolchain { toolchainCompiler = compiler } = getStage (pkgConfigToolchains sharedConfig) Build
350- targets <- validatedTargets (projectConfigShared (projectConfig ctx)) compiler elaboratedPlan targetSelectors
351-
349+ let stage = Build
350+ Toolchain { toolchainCompiler = compiler } = getStage (pkgConfigToolchains sharedConfig) stage
351+ -- FIXME there is total confusion here about who is filtering for the stage
352+ targets <-
353+ validatedTargets (projectConfigShared (projectConfig ctx)) compiler elaboratedPlan targetSelectors
352354 let
353- (unitId, _ ) = fromMaybe (error " panic: targets should be non-empty" ) $ safeHead $ Map. toList targets
354- originalDeps = installedUnitId <$> InstallPlan. directDeps elaboratedPlan unitId
355- oci = OriginalComponentInfo unitId originalDeps
356- pkgId = fromMaybe (error $ " cannot find " ++ prettyShow unitId ) $ packageId <$> InstallPlan. lookup elaboratedPlan unitId
355+ (key, _uid ) = fromMaybe (error " panic: targets should be non-empty" ) $ safeHead $ Map. toList targets
356+ originalDeps = Graph. nodeKey <$> InstallPlan. directDeps elaboratedPlan key
357+ oci = OriginalComponentInfo key originalDeps
358+ pkgId = fromMaybe (error $ " cannot find " ++ prettyShow key ) $ packageId <$> InstallPlan. lookup elaboratedPlan key
357359 baseCtx'' = addDepsToProjectTarget (envPackages replEnvFlags) pkgId baseCtx'
358360
359361 return (Just oci, baseCtx'')
@@ -512,6 +514,7 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g
512514 verbosity = fromFlagOrDefault normal (setupVerbosity $ configCommonFlags configFlags)
513515 tempFileOptions = commonSetupTempFileOptions $ configCommonFlags configFlags
514516
517+ -- FIXME: the compiler depends on the stage!!
515518 validatedTargets ctx compiler elaboratedPlan targetSelectors = do
516519 let multi_repl_enabled = multiReplDecision ctx compiler r
517520 -- Interpret the targets on the command line as repl targets
@@ -552,8 +555,8 @@ minMultipleHomeUnitsVersion :: Version
552555minMultipleHomeUnitsVersion = mkVersion [9 , 4 ]
553556
554557data OriginalComponentInfo = OriginalComponentInfo
555- { ociUnitId :: UnitId
556- , ociOriginalDeps :: [UnitId ]
558+ { ociUnitId :: WithStage UnitId
559+ , ociOriginalDeps :: [WithStage UnitId ]
557560 }
558561 deriving (Show )
559562
@@ -588,17 +591,18 @@ addDepsToProjectTarget deps pkgId ctx =
588591generateReplFlags :: Bool -> ElaboratedInstallPlan -> OriginalComponentInfo -> [String ]
589592generateReplFlags includeTransitive elaboratedPlan OriginalComponentInfo {.. } = flags
590593 where
591- exeDeps :: [UnitId ]
594+ exeDeps :: [WithStage UnitId ]
592595 exeDeps =
593596 foldMap
594597 (InstallPlan. foldPlanPackage (const [] ) elabOrderExeDependencies)
595598 (InstallPlan. dependencyClosure elaboratedPlan [ociUnitId])
596599
597- deps , deps' , trans , trans' :: [UnitId ]
600+ deps , deps' , trans , trans' :: [WithStage UnitId ]
598601 flags :: [String ]
599- deps = installedUnitId <$> InstallPlan. directDeps elaboratedPlan ociUnitId
602+ deps = Graph. nodeKey <$> InstallPlan. directDeps elaboratedPlan ociUnitId
600603 deps' = deps \\ ociOriginalDeps
601- trans = installedUnitId <$> InstallPlan. dependencyClosure elaboratedPlan deps'
604+
605+ trans = Graph. nodeKey <$> InstallPlan. dependencyClosure elaboratedPlan deps'
602606 trans' = trans \\ ociOriginalDeps
603607 flags =
604608 fmap ((" -package-id " ++ ) . prettyShow) . (\\ exeDeps) $
@@ -751,7 +755,7 @@ selectComponentTarget = selectComponentTargetBasic
751755data ReplProblem
752756 = TargetProblemMatchesMultiple MultiReplDecision TargetSelector [AvailableTarget () ]
753757 | -- | Multiple 'TargetSelector's match multiple targets
754- TargetProblemMultipleTargets MultiReplDecision TargetsMap
758+ TargetProblemMultipleTargets MultiReplDecision TargetsMapS
755759 deriving (Eq , Show )
756760
757761-- | The various error conditions that can occur when matching a
@@ -768,7 +772,7 @@ matchesMultipleProblem decision targetSelector targetsExesBuildable =
768772
769773multipleTargetsProblem
770774 :: MultiReplDecision
771- -> TargetsMap
775+ -> TargetsMapS
772776 -> ReplTargetProblem
773777multipleTargetsProblem decision = CustomTargetProblem . TargetProblemMultipleTargets decision
774778
0 commit comments