git.iko.soy/typeable/cabal2nix
on master help sign in
Distribution/NixOS/Derivation/Cabal.hs: add a field 'testDepends'

Test dependencies are buildInputs required only for building (and running) the test suite.

commit0a09168d4063307505a9a9f39aa416ffd3dec922 authorPeter Simons <simons@cryp.to> dateSun 24 Feb 2013, 21:20 (14 years ago) parent448b428
3 files changed+8−3
src/Cabal2Nix/Generate.hs+3−2 src/Cabal2Nix/Normalize.hs+1 src/Distribution/NixOS/Derivation/Cabal.hs+4−1
src/Cabal2Nix/Generate.hs+3−2
@@ -21,6 +21,7 @@ cabal2nix cabal = normalize $ postProcess MkDerivation
2121 , isLibrary = isJust (Cabal.library tpkg)
2222 , isExecutable = not (null (Cabal.executables tpkg))
2323 , buildDepends = map unDep deps
24+ , testDepends = map unDep (concatMap Cabal.targetBuildDepends tstDeps)
2425 , buildTools = map unDep tools
2526 , extraLibs = libs
2627 , pkgConfDeps = pcs
@@ -41,10 +42,10 @@ cabal2nix cabal = normalize $ postProcess MkDerivation
4142 where
4243 descr = Cabal.packageDescription cabal
4344 pkg = Cabal.package descr
44− deps = Cabal.buildDepends tpkg ++ concatMap Cabal.targetBuildDepends (libDeps ++ exeDeps ++ tstDeps)
45+ deps = Cabal.buildDepends tpkg
4546 libDeps = map Cabal.libBuildInfo (maybeToList (Cabal.library tpkg))
4647 exeDeps = map Cabal.buildInfo (Cabal.executables tpkg)
47− tstDeps = map Cabal.testBuildInfo (filter Cabal.testEnabled (Cabal.testSuites tpkg))
48+ tstDeps = map Cabal.testBuildInfo (Cabal.testSuites tpkg)
4849 tools = concatMap Cabal.buildTools (libDeps ++ exeDeps ++ tstDeps)
4950 libs = concatMap Cabal.extraLibs (libDeps ++ exeDeps ++ tstDeps)
5051 pcs = map unDep (concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps ++ tstDeps))
src/Cabal2Nix/Normalize.hs+1
@@ -12,6 +12,7 @@ import Data.Function
1212normalize :: Derivation -> Derivation
1313normalize deriv@(MkDerivation {..}) = deriv
1414 { buildDepends = normalizeNixNames (filter (`notElem` (pname : corePackages)) buildDepends)
15+ , testDepends = normalizeNixNames (filter (`notElem` (pname : corePackages)) testDepends)
1516 , buildTools = normalizeNixBuildTools (filter (`notElem` coreBuildTools) buildTools)
1617 , extraLibs = normalizeNixLibs extraLibs
1718 , pkgConfDeps = normalizeNixLibs pkgConfDeps
src/Distribution/NixOS/Derivation/Cabal.hs+4−1
@@ -47,6 +47,7 @@ data Derivation = MkDerivation
4747 , isLibrary :: Bool
4848 , isExecutable :: Bool
4949 , buildDepends :: [String]
50+ , testDepends :: [String]
5051 , buildTools :: [String]
5152 , extraLibs :: [String]
5253 , pkgConfDeps :: [String]
@@ -78,6 +79,7 @@ renderDerivation deriv = funargs (map text ("cabal" : inputs)) $$ vcat
7879 , boolattr "isLibrary" (not (isLibrary deriv) || isExecutable deriv) (isLibrary deriv)
7980 , boolattr "isExecutable" (not (isLibrary deriv) || isExecutable deriv) (isExecutable deriv)
8081 , listattr "buildDepends" (buildDepends deriv)
82+ , listattr "testDepends" (testDepends deriv)
8183 , listattr "buildTools" (buildTools deriv)
8284 , listattr "extraLibraries" (extraLibs deriv)
8385 , listattr "pkgconfigDepends" (pkgConfDeps deriv)
@@ -93,7 +95,7 @@ renderDerivation deriv = funargs (map text ("cabal" : inputs)) $$ vcat
9395 ]
9496 where
9597 inputs = nub $ sortBy (compare `on` map toLower) $ filter (/="cabal") $ filter (not . isPrefixOf "self.") $
96− buildDepends deriv ++ buildTools deriv ++ extraLibs deriv ++ pkgConfDeps deriv
98+ buildDepends deriv ++ testDepends deriv ++ buildTools deriv ++ extraLibs deriv ++ pkgConfDeps deriv
9799 renderedFlags = [ text "-f" <> (if enable then empty else char '-') <> text f | (FlagName f, enable) <- cabalFlags deriv ]
98100 ++ map text (configureFlags deriv)
99101
@@ -120,6 +122,7 @@ parseDerivation buf
120122 , isLibrary = False
121123 , isExecutable = False
122124 , buildDepends = []
125+ , testDepends = []
123126 , buildTools = []
124127 , extraLibs = []
125128 , pkgConfDeps = []