git.iko.soy/typeable/stackage2nix
on master help sign in
Add: build extra-deps
commit39640c97970786c0b1e80f4d047e269221e345fa authorDmitry Bushev <bushevdv@gmail.com> dateSat 27 May 2017, 20:33 (9 years ago) parent3382b6a
4 files changed+47−5
src/Distribution/Nixpkgs/Haskell/Packages/PrettyPrinting.hs+3−1 src/Distribution/Nixpkgs/Haskell/Stack/PrettyPrinting.hs+39 src/Runner.hs+2−2 stack2nix.cabal+3−2
src/Distribution/Nixpkgs/Haskell/Packages/PrettyPrinting.hs+3−1
@@ -12,7 +12,9 @@ packageSetConfig :: Doc -> Doc
1212packageSetConfig body = vcat
1313 [ funargs ["pkgs", "stdenv", "callPackage"]
1414 , ""
15− , funarg "self" <+> body ]
15+ , funargsCurried ["self"] <+> "{"
16+ , nest 2 body
17+ , "}"]
1618
1719overrides :: Doc -> Doc
1820overrides body = funargsCurried ["self", "super"] <+> body
src/Distribution/Nixpkgs/Haskell/Stack/PrettyPrinting.hsnew file+39
@@ -0,0 +1,39 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+
3+module Distribution.Nixpkgs.Haskell.Stack.PrettyPrinting where
4+
5+import Control.Lens
6+import Distribution.Package
7+import Distribution.Text
8+import Distribution.Nixpkgs.Haskell.Derivation
9+import Distribution.Nixpkgs.Haskell.Packages.PrettyPrinting as PP
10+import Language.Nix.PrettyPrinting as PP
11+
12+
13+overrideExtraDeps :: [Derivation] -> Doc
14+overrideExtraDeps deps = PP.packageSetConfig . PP.cat $ callPackage <$> deps
15+ where
16+ drvNameString = PP.doubleQuotes . disp . pkgName . view pkgid
17+ callPackage drv = vcat
18+ [ drvNameString drv <> " = callPackage",
19+ nest 2 (PP.parens $ PP.pPrint drv) <+> "{};"]
20+
21+overrideHaskellPackages :: [Derivation] -> Doc -> Doc
22+overrideHaskellPackages extraDeps ghc = vcat
23+ [ funargs ["nixpkgs ? import <nixpkgs> {}"]
24+ , ""
25+ , "with nixpkgs;"
26+ , "let"
27+ , nest 2 $ vcat
28+ [ "extraDepsPackages ="
29+ , overrideExtraDeps extraDeps <> semi
30+ , "pkgOverrides = self: extraDepsPackages {"
31+ , nest 2 "inherit pkgs stdenv;"
32+ , nest 2 "inherit (self) callPackage;"
33+ , "};"
34+ ]
35+ , "in pkgs.haskell.packages." <> ghc <> ".override {"
36+ , nest 2 $ vcat
37+ [ "overrides = self: pkgOverrides self;"]
38+ , "}"
39+ ]
src/Runner.hs+2−2
@@ -5,6 +5,7 @@ module Runner where
55import Cli
66import Control.Lens
77import Distribution.Nixpkgs.Haskell.Stack
8+import Distribution.Nixpkgs.Haskell.Stack.PrettyPrinting as PP
89import Distribution.PackageDescription ( FlagName(..), FlagAssignment )
910import Distribution.Simple.Utils ( lowercase )
1011import Language.Nix.PrettyPrinting as PP
@@ -22,9 +23,8 @@ run :: IO ()
2223run = do
2324 Options{..} <- execParser pinfo
2425 stackYaml <- either fail pure =<< readStackConfig optStackYaml
25− print $ stackYaml ^. scExtraDeps
2626 derivations <- traverse (extraDepDerivation optHackageDb optPlatform optCompilerId (readFlagList optFlags))
2727 $ stackYaml ^. scExtraDeps
28− let out = PP.cat $ PP.pPrint <$> derivations
28+ let out = PP.overrideHaskellPackages derivations (PP.text "ghc802")
2929 print out
3030 --print $ nixpkgsOverride overrideConfigFixture
stack2nix.cabal+3−2
@@ -16,6 +16,7 @@ library
1616 exposed-modules: Cli
1717 , Distribution.Nixpkgs.Haskell.Packages.PrettyPrinting
1818 , Distribution.Nixpkgs.Haskell.Stack
19+ , Distribution.Nixpkgs.Haskell.Stack.PrettyPrinting
1920 , Runner
2021 , Stack.Config
2122 , Stack.Config.Yaml
@@ -38,7 +39,7 @@ library
3839executable stack2nix
3940 hs-source-dirs: app
4041 main-is: Main.hs
41− ghc-options: -threaded -rtsopts -with-rtsopts=-N
42+ ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
4243 build-depends: base
4344 , stack2nix
4445 default-language: Haskell2010
@@ -57,7 +58,7 @@ test-suite spec
5758 default-extensions: OverloadedStrings
5859 other-modules: PrettyPrintingSpec
5960 , Stack.Config.YamlSpec
60− ghc-options: -threaded -rtsopts -with-rtsopts=-N
61+ ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
6162 default-language: Haskell2010
6263
6364source-repository head