git.iko.soy/typeable/stackage2nix
on master help sign in
Support overriding the `nixpkgs` to use. (#11)
0d49276Nicholas Clarke
src/Distribution/Nixpkgs/Haskell/Stack/PrettyPrinting.hs+9−10
@@ -20,7 +20,9 @@ import Language.Nix.PrettyPrinting as PP
20data OverrideConfig = OverrideConfig
20data OverrideConfig = OverrideConfig
21 { _ocGhc :: !Version
21 { _ocGhc :: !Version
22 , _ocStackagePackages :: !FilePath
22 , _ocStackagePackages :: !FilePath
23− , _ocStackageConfig :: !FilePath }
23+ , _ocStackageConfig :: !FilePath
24+ , _ocNixpkgs :: !FilePath
25+ }
24
26
25makeLenses ''OverrideConfig
27makeLenses ''OverrideConfig
26
28
@@ -43,20 +45,16 @@ importStackagePackages path = hsep
43 , "}"
45 , "}"
44 ]
46 ]
45
47
46−importStackageConfig :: FilePath -> Doc
47−importStackageConfig path = hsep
48− [ "import", disp (fromString path :: Nix.FilePath), "{"
49− , "inherit pkgs;"
50− , "}"
51− ]
52−
53callStackageConfig :: FilePath -> Doc
48callStackageConfig :: FilePath -> Doc
54callStackageConfig path = hsep
49callStackageConfig path = hsep
55 [ "callPackage", disp (fromString path :: Nix.FilePath), "{}"]
50 [ "callPackage", disp (fromString path :: Nix.FilePath), "{}"]
56
51
57overrideHaskellPackages :: OverrideConfig -> NonEmpty Derivation -> Doc
52overrideHaskellPackages :: OverrideConfig -> NonEmpty Derivation -> Doc
58overrideHaskellPackages oc packages = vcat
53overrideHaskellPackages oc packages = vcat
59− [ funargs ["nixpkgs ? import <nixpkgs> {}"]
54+ [ funargs ["nixpkgs ? import "
55+ <> disp (fromString (oc ^. ocNixpkgs) :: Nix.FilePath)
56+ <> " {}"
57+ ]
60 , ""
58 , ""
61 , "with nixpkgs;"
59 , "with nixpkgs;"
62 , "let"
60 , "let"
@@ -74,10 +72,11 @@ overrideHaskellPackages oc packages = vcat
74 , "};"
72 , "};"
75 , ""
73 , ""
76 ]
74 ]
77− , "in callPackage <nixpkgs/pkgs/development/haskell-modules> {"
75+ , "in callPackage (nixpkgs.path + \"/pkgs/development/haskell-modules\") {"
78 , nest 2 $ vcat
76 , nest 2 $ vcat
79 [ attr "ghc" ("pkgs.haskell.compiler." <> toNixGhcVersion (oc ^. ocGhc))
77 [ attr "ghc" ("pkgs.haskell.compiler." <> toNixGhcVersion (oc ^. ocGhc))
80 , attr "compilerConfig" "self: extends pkgOverrides (extends stackageConfig (stackagePackages self))"
78 , attr "compilerConfig" "self: extends pkgOverrides (extends stackageConfig (stackagePackages self))"
79+ , attr "haskellLib" "callPackage (nixpkgs.path + \"/pkgs/development/haskell-modules/lib.nix\") {}"
81 ]
80 ]
82 , "}"
81 , "}"
83 ]
82 ]
src/Language/Nix/FilePath.hs+4−1
@@ -43,4 +43,7 @@ parseFilePath = do
43 else pfail
43 else pfail
44
44
45renderFilePath :: FilePath -> String
45renderFilePath :: FilePath -> String
46−renderFilePath = Posix.combine "." . Posix.normalise . unFilePath
46+renderFilePath = Posix.combine "."
47+ . Posix.normalise
48+ . Posix.dropTrailingPathSeparator
49+ . unFilePath
src/Runner.hs+3−1
@@ -78,7 +78,9 @@ mkOverrideConfig :: Options -> Version -> OverrideConfig
78mkOverrideConfig opts ghcVersion = OverrideConfig
78mkOverrideConfig opts ghcVersion = OverrideConfig
79 { _ocGhc = ghcVersion
79 { _ocGhc = ghcVersion
80 , _ocStackagePackages = opts ^. optOutStackagePackages
80 , _ocStackagePackages = opts ^. optOutStackagePackages
81− , _ocStackageConfig = opts ^. optOutStackageConfig }
81+ , _ocStackageConfig = opts ^. optOutStackageConfig
82+ , _ocNixpkgs = opts ^. optNixpkgsRepository
83+ }
82
84
83mkS2nOptions :: StackConfig -> Options -> S2n.Options
85mkS2nOptions :: StackConfig -> Options -> S2n.Options
84mkS2nOptions conf opts = S2n.Options
86mkS2nOptions conf opts = S2n.Options