Skip to content

Commit 8729064

Browse files
authored
Merge pull request #230 from dajmaki/feat-impl-flag
Add flag --compiler-id flag.
2 parents db53146 + fa93bd0 commit 8729064

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cabal2nix/src/Main.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Distribution.Nixpkgs.Meta
1515
import Distribution.PackageDescription ( FlagName(..), FlagAssignment )
1616
import Distribution.Simple.Utils ( lowercase )
1717
import Distribution.System
18-
import Distribution.Text ( display )
18+
import Distribution.Text ( display, simpleParse )
1919
import Language.Nix
2020
import Options.Applicative
2121
import Paths_cabal2nix
@@ -41,6 +41,7 @@ data Options = Options
4141
, optHackageDb :: Maybe FilePath
4242
, optNixShellOutput :: Bool
4343
, optFlags :: [String]
44+
, optCompilerId :: Maybe String
4445
, optUrl :: String
4546
}
4647
deriving (Show)
@@ -62,6 +63,7 @@ options = Options
6263
<*> optional (strOption $ long "hackage-db" <> metavar "PATH" <> help "path to the local hackage db in tar format")
6364
<*> switch (long "shell" <> help "generate output suitable for nix-shell")
6465
<*> many (strOption $ short 'f' <> long "flag" <> help "Cabal flag (may be specified multiple times)")
66+
<*> optional (strOption $ long "compiler-id" <> help "Compiler identifier to use when evaluating cabal file")
6567
<*> strArgument (metavar "URI")
6668

6769
pinfo :: ParserInfo Options
@@ -97,11 +99,15 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> do
9799

98100
pkg <- getPackage optHackageDb $ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256)
99101

100-
let deriv :: Derivation
102+
let
103+
compilerId :: CompilerId
104+
compilerId = fromMaybe buildCompilerId (optCompilerId >>= simpleParse)
105+
106+
deriv :: Derivation
101107
deriv = fromGenericPackageDescription (const True)
102108
(\i -> Just (binding # (i, path # [i])))
103109
buildPlatform
104-
(unknownCompilerInfo buildCompilerId NoAbiTag)
110+
(unknownCompilerInfo compilerId NoAbiTag)
105111
(readFlagList optFlags)
106112
[]
107113
(pkgCabal pkg)

0 commit comments

Comments
 (0)