11{-# LANGUAGE DeriveGeneric #-}
2+ {-# LANGUAGE RankNTypes #-}
23{-# LANGUAGE RecordWildCards #-}
34{-# LANGUAGE TemplateHaskell #-}
45{-# LANGUAGE TupleSections #-}
@@ -10,6 +11,7 @@ module Distribution.Nixpkgs.Haskell.Derivation
1011 , cabalFlags , runHaddock , jailbreak , doCheck , doBenchmark , testFlags , testTargets , hyperlinkSource
1112 , enableLibraryProfiling , enableExecutableProfiling , phaseOverrides , editedCabalFile , metaSection
1213 , dependencies , setupDepends , benchmarkDepends , enableSeparateDataOutput , extraAttributes
14+ , focusBuildInfo
1315 )
1416 where
1517
@@ -47,10 +49,10 @@ data Derivation = MkDerivation
4749 , _extraFunctionArgs :: Set Binding
4850 , _extraAttributes :: Map String String
4951 , _setupDepends :: BuildInfo
50- , _libraryDepends :: BuildInfo
51- , _executableDepends :: BuildInfo
52- , _testDepends :: BuildInfo
53- , _benchmarkDepends :: BuildInfo
52+ , _libraryDepends :: [( BuildInfo , Bool )]
53+ , _executableDepends :: [( BuildInfo , Bool )]
54+ , _testDepends :: [( BuildInfo , Bool )]
55+ , _benchmarkDepends :: [( BuildInfo , Bool )]
5456 , _configureFlags :: Set String
5557 , _cabalFlags :: FlagAssignment
5658 , _runHaddock :: Bool
@@ -103,7 +105,14 @@ nullDerivation = MkDerivation
103105
104106makeLenses ''Derivation
105107
106- makeLensesFor (fmap (," dependencies" ) [" _setupDepends" , " _libraryDepends" , " _executableDepends" , " _testDepends" , " _benchmarkDepends" ]) ''Derivation
108+ makeLensesFor (fmap (," nonSetupDependencies" ) [" _libraryDepends" , " _executableDepends" , " _testDepends" , " _benchmarkDepends" ]) ''Derivation
109+
110+ dependencies :: Traversal' Derivation BuildInfo
111+ dependencies = traversal $ \ focus drv ->
112+ liftA2 (set setupDepends) (focus $ view setupDepends drv) ((nonSetupDependencies . traverse . _1) focus drv)
113+
114+ focusBuildInfo :: Lens' Derivation [(BuildInfo , Bool )] -> Traversal' Derivation BuildInfo
115+ focusBuildInfo l = l . traverse . _1
107116
108117instance Package Derivation where
109118 packageId = view pkgid
@@ -125,10 +134,10 @@ instance Pretty Derivation where
125134 , boolattr " isExecutable" (not _isLibrary || _isExecutable) _isExecutable
126135 , boolattr " enableSeparateDataOutput" _enableSeparateDataOutput _enableSeparateDataOutput
127136 , pPrintBuildInfo " setup" _setupDepends
128- , pPrintBuildInfo " library" _libraryDepends
129- , pPrintBuildInfo " executable" _executableDepends
130- , pPrintBuildInfo " test" _testDepends
131- , pPrintBuildInfo " benchmark" _benchmarkDepends
137+ , pPrintBuildInfo' " library" _libraryDepends
138+ , pPrintBuildInfo' " executable" _executableDepends
139+ , pPrintBuildInfo' " test" _testDepends
140+ , pPrintBuildInfo' " benchmark" _benchmarkDepends
132141 , boolattr " enableLibraryProfiling" _enableLibraryProfiling _enableLibraryProfiling
133142 , boolattr " enableExecutableProfiling" _enableExecutableProfiling _enableExecutableProfiling
134143 , boolattr " doHaddock" (not _runHaddock) _runHaddock
@@ -145,6 +154,9 @@ instance Pretty Derivation where
145154 , rbrace
146155 ]
147156 where
157+ pPrintBuildInfo' :: String -> [(BuildInfo , Bool )] -> Doc
158+ pPrintBuildInfo' name = pPrintBuildInfo name . foldMap fst . filter snd
159+
148160 inputs :: Set String
149161 inputs = Set. unions [ Set. map (view (localName . ident)) _extraFunctionArgs
150162 , setOf (dependencies . each . folded . localName . ident) drv
0 commit comments