git.iko.soy/typeable/stackage2nix
on master help sign in
Add: set ghc version from build plan
4bc87ffDmitry Bushev
src/Distribution/Nixpkgs/Haskell/Stack/PrettyPrinting.hs+7−4
@@ -11,12 +11,13 @@ import Distribution.Nixpkgs.Haskell.Derivation
11import Distribution.Nixpkgs.Haskell.Packages.PrettyPrinting as PP
11import Distribution.Nixpkgs.Haskell.Packages.PrettyPrinting as PP
12import Distribution.Package
12import Distribution.Package
13import Distribution.Text
13import Distribution.Text
14+import Distribution.Version (Version(..))
14import qualified Language.Nix.FilePath as Nix
15import qualified Language.Nix.FilePath as Nix
15import Language.Nix.PrettyPrinting as PP
16import Language.Nix.PrettyPrinting as PP
16
17
17
18
18data OverrideConfig = OverrideConfig
19data OverrideConfig = OverrideConfig
19− { _ocGhc :: !String
20+ { _ocGhc :: !Version
20 , _ocStackagePackages :: !FilePath
21 , _ocStackagePackages :: !FilePath
21 , _ocStackageConfig :: !FilePath }
22 , _ocStackageConfig :: !FilePath }
22
23
@@ -74,10 +75,12 @@ overrideHaskellPackages oc packages = vcat
74 ]
75 ]
75 , "in callPackage <nixpkgs/pkgs/development/haskell-modules> {"
76 , "in callPackage <nixpkgs/pkgs/development/haskell-modules> {"
76 , nest 2 $ vcat
77 , nest 2 $ vcat
77− [ attr "ghc" ("pkgs.haskell.compiler." <> ghc)
78+ [ attr "ghc" ("pkgs.haskell.compiler." <> toNixGhcVersion (oc ^. ocGhc))
78 , attr "compilerConfig" "self: extends stackageConfig (stackagePackages self)"
79 , attr "compilerConfig" "self: extends stackageConfig (stackagePackages self)"
79 , attr "overrides" "self: pkgOverrides self"]
80 , attr "overrides" "self: pkgOverrides self"]
80 , "}"
81 , "}"
81 ]
82 ]
82− where
83+
83− ghc = oc ^. ocGhc . to text
84+toNixGhcVersion :: Version -> Doc
85+toNixGhcVersion =
86+ (<>) "ghc" . text . filter (/= '.') . show . disp
src/Runner.hs+7−5
@@ -3,9 +3,11 @@ module Runner ( run ) where
3import Control.Lens
3import Control.Lens
4import Distribution.Nixpkgs.Haskell.Stack
4import Distribution.Nixpkgs.Haskell.Stack
5import Distribution.Nixpkgs.Haskell.Stack.PrettyPrinting as PP
5import Distribution.Nixpkgs.Haskell.Stack.PrettyPrinting as PP
6+import Distribution.Version (Version(..))
6import Options.Applicative
7import Options.Applicative
7import Runner.Cli
8import Runner.Cli
8import Stack.Config
9import Stack.Config
10+import Stackage.Types
9
11
10import qualified Stackage2nix as S2n
12import qualified Stackage2nix as S2n
11
13
@@ -24,12 +26,12 @@ run = do
24 , S2n.optNixpkgsMap = Nothing
26 , S2n.optNixpkgsMap = Nothing
25 , S2n.optOutPackages = opts ^. optStackageOutPackages
27 , S2n.optOutPackages = opts ^. optStackageOutPackages
26 , S2n.optOutConfig = opts ^. optStackageOutConfig }
28 , S2n.optOutConfig = opts ^. optStackageOutConfig }
27− _ <- S2n.run s2nOptions
29+ buildPlan <- S2n.run s2nOptions
28
30
29 -- generate haskell packages override
31 -- generate haskell packages override
30 let
32 let
31 pkgConfig = mkPackageConfig (opts ^. optPlatform) (opts ^. optCompilerId)
33 pkgConfig = mkPackageConfig (opts ^. optPlatform) (opts ^. optCompilerId)
32− overrideConfig = mkOverrideConfig opts
34+ overrideConfig = mkOverrideConfig opts (siGhcVersion $ bpSystemInfo buildPlan)
33 packages <- traverse (packageDerivation pkgConfig (opts ^. optHackageDb))
35 packages <- traverse (packageDerivation pkgConfig (opts ^. optHackageDb))
34 $ stackYaml ^. scPackages
36 $ stackYaml ^. scPackages
35 let
37 let
@@ -38,8 +40,8 @@ run = do
38 writeFile (opts ^. optOutFile) (show out)
40 writeFile (opts ^. optOutFile) (show out)
39 putStrLn $ "\nDerivation was written to " ++ opts ^. optOutFile
41 putStrLn $ "\nDerivation was written to " ++ opts ^. optOutFile
40
42
41−mkOverrideConfig :: Options -> OverrideConfig
43+mkOverrideConfig :: Options -> Version -> OverrideConfig
42−mkOverrideConfig opts = OverrideConfig
44+mkOverrideConfig opts ghcVersion = OverrideConfig
43− { _ocGhc = "ghc802"
45+ { _ocGhc = ghcVersion
44 , _ocStackagePackages = opts ^. optStackageOutPackages
46 , _ocStackagePackages = opts ^. optStackageOutPackages
45 , _ocStackageConfig = opts ^. optStackageOutConfig }
47 , _ocStackageConfig = opts ^. optStackageOutConfig }
stack.yaml+2−1
@@ -2,10 +2,11 @@ resolver: lts-8.15
2packages:
2packages:
3- '.'
3- '.'
4- location: ../cabal2nix
4- location: ../cabal2nix
5+ extra-dep: true
5#- location:
6#- location:
6 #git: https://github.com/4e6/cabal2nix.git
7 #git: https://github.com/4e6/cabal2nix.git
7 #commit: 5da88077431fca9ec4d63ce3ad22cd1fe935ad93
8 #commit: 5da88077431fca9ec4d63ce3ad22cd1fe935ad93
8− extra-dep: true
9+ #extra-dep: true
9extra-deps:
10extra-deps:
10- distribution-nixpkgs-1.1
11- distribution-nixpkgs-1.1
11- hopenssl-2.2
12- hopenssl-2.2
stack2nix.cabal+1
@@ -38,6 +38,7 @@ library
38 , network-uri
38 , network-uri
39 , optparse-applicative
39 , optparse-applicative
40 , pretty
40 , pretty
41+ , stackage-curator
41 , text
42 , text
42 , yaml
43 , yaml
43 default-language: Haskell2010
44 default-language: Haskell2010
test.sh+2
@@ -2,6 +2,8 @@
2
2
3VERSION=${VERSION:-8.15}
3VERSION=${VERSION:-8.15}
4
4
5+set -x
6+
5stack2nix \
7stack2nix \
6 --stackage-build-plan "$HOME/projects/fpco/lts-haskell/lts-$VERSION.yaml" \
8 --stackage-build-plan "$HOME/projects/fpco/lts-haskell/lts-$VERSION.yaml" \
7 --all-cabal-hashes "$HOME/projects/commercialhaskell/all-cabal-hashes" \
9 --all-cabal-hashes "$HOME/projects/commercialhaskell/all-cabal-hashes" \