1 {-# LANGUAGE StandaloneDeriving #-}
3 -- | Command line options for nix-style / v2 commands.
5 -- The commands take a lot of the same options, which affect how install plan
7 module Distribution
.Client
.NixStyleOptions
10 , defaultNixStyleFlags
11 , updNixStyleCommonSetupFlags
14 import Distribution
.Client
.Compat
.Prelude
17 import Distribution
.Simple
.Command
(OptionField
(..), ShowOrParseArgs
)
18 import Distribution
.Simple
.Setup
19 ( BenchmarkFlags
(benchmarkCommonFlags
)
20 , CommonSetupFlags
(..)
22 , TestFlags
(testCommonFlags
)
24 import Distribution
.Solver
.Types
.ConstraintSource
(ConstraintSource
(..))
26 import Distribution
.Client
.ProjectFlags
31 import Distribution
.Client
.Setup
44 data NixStyleFlags a
= NixStyleFlags
45 { configFlags
:: ConfigFlags
46 , configExFlags
:: ConfigExFlags
47 , installFlags
:: InstallFlags
48 , haddockFlags
:: HaddockFlags
49 , testFlags
:: TestFlags
50 , benchmarkFlags
:: BenchmarkFlags
51 , projectFlags
:: ProjectFlags
56 :: (ShowOrParseArgs
-> [OptionField a
])
58 -> [OptionField
(NixStyleFlags a
)]
59 nixStyleOptions commandOptions showOrParseArgs
=
63 -- Note: [Hidden Flags]
64 -- We reuse the configure options from v1 commands which on their turn
65 -- reuse the ones from Cabal) but we hide some of them in v2 commands.
71 , "promised-dependency"
72 , "exact-configuration"
77 $ configureOptions showOrParseArgs
84 ConstraintSourceCommandlineFlag
89 -- hide "target-package-db" and "symlink-bindir" flags from the
91 -- "symlink-bindir" is obsoleted by "installdir" in ClientInstallFlags
93 ( (`
notElem`
["target-package-db", "symlink-bindir"])
96 $ installOptions showOrParseArgs
101 -- hide "verbose" and "builddir" flags from the
104 ( (`
notElem`
["v", "verbose", "builddir"])
107 $ haddockOptions showOrParseArgs
109 ++ liftOptions testFlags set5
(testOptions showOrParseArgs
)
110 ++ liftOptions benchmarkFlags set6
(benchmarkOptions showOrParseArgs
)
111 ++ liftOptions projectFlags set7
(projectFlagsOptions showOrParseArgs
)
112 ++ liftOptions extraFlags set8
(commandOptions showOrParseArgs
)
114 set1 x flags
= flags
{configFlags
= x
}
115 set2 x flags
= flags
{configExFlags
= x
}
116 set3 x flags
= flags
{installFlags
= x
}
117 set4 x flags
= flags
{haddockFlags
= x
}
118 set5 x flags
= flags
{testFlags
= x
}
119 set6 x flags
= flags
{benchmarkFlags
= x
}
120 set7 x flags
= flags
{projectFlags
= x
}
121 set8 x flags
= flags
{extraFlags
= x
}
123 defaultNixStyleFlags
:: a
-> NixStyleFlags a
124 defaultNixStyleFlags x
=
126 { configFlags
= mempty
127 , configExFlags
= mempty
128 , installFlags
= mempty
129 , haddockFlags
= mempty
131 , benchmarkFlags
= mempty
132 , projectFlags
= defaultProjectFlags
136 updNixStyleCommonSetupFlags
137 :: (CommonSetupFlags
-> CommonSetupFlags
)
140 updNixStyleCommonSetupFlags setFlag nixFlags
=
143 let flags
= configFlags nixFlags
144 common
= configCommonFlags flags
145 in flags
{configCommonFlags
= setFlag common
}
147 let flags
= haddockFlags nixFlags
148 common
= haddockCommonFlags flags
149 in flags
{haddockCommonFlags
= setFlag common
}
151 let flags
= testFlags nixFlags
152 common
= testCommonFlags flags
153 in flags
{testCommonFlags
= setFlag common
}
155 let flags
= benchmarkFlags nixFlags
156 common
= benchmarkCommonFlags flags
157 in flags
{benchmarkCommonFlags
= setFlag common
}