@@ -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,8 @@ 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!!
518+ validatedTargets :: ProjectConfigShared -> Compiler -> ElaboratedInstallPlan -> [TargetSelector ] -> IO TargetsMapS
515519 validatedTargets ctx compiler elaboratedPlan targetSelectors = do
516520 let multi_repl_enabled = multiReplDecision ctx compiler r
517521 -- Interpret the targets on the command line as repl targets
@@ -552,8 +556,8 @@ minMultipleHomeUnitsVersion :: Version
552556minMultipleHomeUnitsVersion = mkVersion [9 , 4 ]
553557
554558data OriginalComponentInfo = OriginalComponentInfo
555- { ociUnitId :: UnitId
556- , ociOriginalDeps :: [UnitId ]
559+ { ociUnitId :: WithStage UnitId
560+ , ociOriginalDeps :: [WithStage UnitId ]
557561 }
558562 deriving (Show )
559563
@@ -588,17 +592,18 @@ addDepsToProjectTarget deps pkgId ctx =
588592generateReplFlags :: Bool -> ElaboratedInstallPlan -> OriginalComponentInfo -> [String ]
589593generateReplFlags includeTransitive elaboratedPlan OriginalComponentInfo {.. } = flags
590594 where
591- exeDeps :: [UnitId ]
595+ exeDeps :: [WithStage UnitId ]
592596 exeDeps =
593597 foldMap
594598 (InstallPlan. foldPlanPackage (const [] ) elabOrderExeDependencies)
595599 (InstallPlan. dependencyClosure elaboratedPlan [ociUnitId])
596600
597- deps , deps' , trans , trans' :: [UnitId ]
601+ deps , deps' , trans , trans' :: [WithStage UnitId ]
598602 flags :: [String ]
599- deps = installedUnitId <$> InstallPlan. directDeps elaboratedPlan ociUnitId
603+ deps = Graph. nodeKey <$> InstallPlan. directDeps elaboratedPlan ociUnitId
600604 deps' = deps \\ ociOriginalDeps
601- trans = installedUnitId <$> InstallPlan. dependencyClosure elaboratedPlan deps'
605+
606+ trans = Graph. nodeKey <$> InstallPlan. dependencyClosure elaboratedPlan deps'
602607 trans' = trans \\ ociOriginalDeps
603608 flags =
604609 fmap ((" -package-id " ++ ) . prettyShow) . (\\ exeDeps) $
@@ -751,7 +756,7 @@ selectComponentTarget = selectComponentTargetBasic
751756data ReplProblem
752757 = TargetProblemMatchesMultiple MultiReplDecision TargetSelector [AvailableTarget () ]
753758 | -- | Multiple 'TargetSelector's match multiple targets
754- TargetProblemMultipleTargets MultiReplDecision TargetsMap
759+ TargetProblemMultipleTargets MultiReplDecision TargetsMapS
755760 deriving (Eq , Show )
756761
757762-- | The various error conditions that can occur when matching a
@@ -768,7 +773,7 @@ matchesMultipleProblem decision targetSelector targetsExesBuildable =
768773
769774multipleTargetsProblem
770775 :: MultiReplDecision
771- -> TargetsMap
776+ -> TargetsMapS
772777 -> ReplTargetProblem
773778multipleTargetsProblem decision = CustomTargetProblem . TargetProblemMultipleTargets decision
774779
0 commit comments