@@ -55,23 +55,28 @@ nixOptsFromMonoid NixOptsMonoid{..} os = do
5555
5656nixCompiler :: CompilerVersion a -> Either StringException T. Text
5757nixCompiler compilerVersion =
58- let -- These are the latest minor versions for each respective major version available in nixpkgs
59- fixMinor " 8.2" = " 8.2.1"
60- fixMinor " 8.0" = " 8.0.2"
61- fixMinor " 7.10" = " 7.10.3"
62- fixMinor " 7.8" = " 7.8.4"
63- fixMinor " 7.6" = " 7.6.3"
64- fixMinor " 7.4" = " 7.4.2"
65- fixMinor " 7.2" = " 7.2.2"
66- fixMinor " 6.12" = " 6.12.3"
67- fixMinor " 6.10" = " 6.10.4"
68- fixMinor v = v
69- nixCompilerFromVersion v = T. append (T. pack " haskell.compiler.ghc" )
70- (T. filter (/= ' .' )
71- (fixMinor (versionText v)))
72- in case compilerVersion of
73- GhcVersion v -> Right $ nixCompilerFromVersion v
74- _ -> Left $ stringException " Only GHC is supported by stack --nix"
58+ case compilerVersion of
59+ GhcVersion version ->
60+ case T. split (== ' .' ) (versionText version) of
61+ x : y : minor ->
62+ Right $
63+ case minor of
64+ [] ->
65+ -- The minor version is not specified. Select the latest minor
66+ -- version in Nixpkgs corresponding to the requested major
67+ -- version.
68+ let major = T. concat [x, y] in
69+ " (let compilers = builtins.filter \
70+ \(name: builtins.match \
71+ \\" ghc" <> major <> " [[:digit:]]*\" name != null) \
72+ \(lib.attrNames haskell.compiler); in \
73+ \if compilers == [] \
74+ \then abort \" No compiler found for GHC "
75+ <> versionText version <> " \" \
76+ \else haskell.compiler.${builtins.head compilers})"
77+ _ -> " haskell.compiler.ghc" <> T. concat (x : y : minor)
78+ _ -> Left $ stringException " GHC major version not specified"
79+ _ -> Left $ stringException " Only GHC is supported by stack --nix"
7580
7681-- Exceptions thown specifically by Stack.Nix
7782data StackNixException
0 commit comments