git.iko.soy/typeable/stackage2nix
on master help sign in
Support overriding the `nixpkgs` to use. (#11)

* Fix build with recent nixpkgs. As per https://github.com/NixOS/nixpkgs/commit/74f5fe50681003f075bf0b1ff811d0c0cd7c64f3 * Use `callPackage` in place of `import`. * Remove unused function. * Trim trailing separator from Nix FilePath. This causes a parse error in .nix files. * Make use of nixpkgs argument. Previously this was not used. * Use `nixpkgs.path`.

commit0d492768538c3aff3b49a0fd43c85ddd3628e3cf authorNicholas Clarke <nick@topos.org.uk> dateTue 15 Aug 2017, 20:10 (9 years ago) parent1df506f
3 files changed+16−12
src/Distribution/Nixpkgs/Haskell/Stack/PrettyPrinting.hs+9−10 src/Language/Nix/FilePath.hs+4−1 src/Runner.hs+3−1
src/Distribution/Nixpkgs/Haskell/Stack/PrettyPrinting.hs+9−10
@@ -20,7 +20,9 @@ import Language.Nix.PrettyPrinting as PP
2020data OverrideConfig = OverrideConfig
2121 { _ocGhc :: !Version
2222 , _ocStackagePackages :: !FilePath
23− , _ocStackageConfig :: !FilePath }
23+ , _ocStackageConfig :: !FilePath
24+ , _ocNixpkgs :: !FilePath
25+ }
2426
2527makeLenses ''OverrideConfig
2628
@@ -43,20 +45,16 @@ importStackagePackages path = hsep
4345 , "}"
4446 ]
4547
46−importStackageConfig :: FilePath -> Doc
47−importStackageConfig path = hsep
48− [ "import", disp (fromString path :: Nix.FilePath), "{"
49− , "inherit pkgs;"
50− , "}"
51− ]
52−
5348callStackageConfig :: FilePath -> Doc
5449callStackageConfig path = hsep
5550 [ "callPackage", disp (fromString path :: Nix.FilePath), "{}"]
5651
5752overrideHaskellPackages :: OverrideConfig -> NonEmpty Derivation -> Doc
5853overrideHaskellPackages oc packages = vcat
59− [ funargs ["nixpkgs ? import <nixpkgs> {}"]
54+ [ funargs ["nixpkgs ? import "
55+ <> disp (fromString (oc ^. ocNixpkgs) :: Nix.FilePath)
56+ <> " {}"
57+ ]
6058 , ""
6159 , "with nixpkgs;"
6260 , "let"
@@ -74,10 +72,11 @@ overrideHaskellPackages oc packages = vcat
7472 , "};"
7573 , ""
7674 ]
77− , "in callPackage <nixpkgs/pkgs/development/haskell-modules> {"
75+ , "in callPackage (nixpkgs.path + \"/pkgs/development/haskell-modules\") {"
7876 , nest 2 $ vcat
7977 [ attr "ghc" ("pkgs.haskell.compiler." <> toNixGhcVersion (oc ^. ocGhc))
8078 , attr "compilerConfig" "self: extends pkgOverrides (extends stackageConfig (stackagePackages self))"
79+ , attr "haskellLib" "callPackage (nixpkgs.path + \"/pkgs/development/haskell-modules/lib.nix\") {}"
8180 ]
8281 , "}"
8382 ]
src/Language/Nix/FilePath.hs+4−1
@@ -43,4 +43,7 @@ parseFilePath = do
4343 else pfail
4444
4545renderFilePath :: 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
7878mkOverrideConfig opts ghcVersion = OverrideConfig
7979 { _ocGhc = ghcVersion
8080 , _ocStackagePackages = opts ^. optOutStackagePackages
81− , _ocStackageConfig = opts ^. optOutStackageConfig }
81+ , _ocStackageConfig = opts ^. optOutStackageConfig
82+ , _ocNixpkgs = opts ^. optNixpkgsRepository
83+ }
8284
8385mkS2nOptions :: StackConfig -> Options -> S2n.Options
8486mkS2nOptions conf opts = S2n.Options