@@ -15,7 +15,7 @@ import Distribution.Nixpkgs.Meta
15
15
import Distribution.PackageDescription ( FlagName (.. ), FlagAssignment )
16
16
import Distribution.Simple.Utils ( lowercase )
17
17
import Distribution.System
18
- import Distribution.Text ( display )
18
+ import Distribution.Text ( display , simpleParse )
19
19
import Language.Nix
20
20
import Options.Applicative
21
21
import Paths_cabal2nix
@@ -41,6 +41,7 @@ data Options = Options
41
41
, optHackageDb :: Maybe FilePath
42
42
, optNixShellOutput :: Bool
43
43
, optFlags :: [String ]
44
+ , optCompilerId :: Maybe String
44
45
, optUrl :: String
45
46
}
46
47
deriving (Show )
@@ -62,6 +63,7 @@ options = Options
62
63
<*> optional (strOption $ long " hackage-db" <> metavar " PATH" <> help " path to the local hackage db in tar format" )
63
64
<*> switch (long " shell" <> help " generate output suitable for nix-shell" )
64
65
<*> 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" )
65
67
<*> strArgument (metavar " URI" )
66
68
67
69
pinfo :: ParserInfo Options
@@ -97,11 +99,15 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> do
97
99
98
100
pkg <- getPackage optHackageDb $ Source optUrl (fromMaybe " " optRevision) (maybe UnknownHash Guess optSha256)
99
101
100
- let deriv :: Derivation
102
+ let
103
+ compilerId :: CompilerId
104
+ compilerId = fromMaybe buildCompilerId (optCompilerId >>= simpleParse)
105
+
106
+ deriv :: Derivation
101
107
deriv = fromGenericPackageDescription (const True )
102
108
(\ i -> Just (binding # (i, path # [i])))
103
109
buildPlatform
104
- (unknownCompilerInfo buildCompilerId NoAbiTag )
110
+ (unknownCompilerInfo compilerId NoAbiTag )
105
111
(readFlagList optFlags)
106
112
[]
107
113
(pkgCabal pkg)
0 commit comments