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
13 import Distribution
.Client
.Compat
.Prelude
16 import Distribution
.Simple
.Command
(OptionField
(..), ShowOrParseArgs
)
17 import Distribution
.Simple
.Setup
(BenchmarkFlags
, HaddockFlags
, TestFlags
)
18 import Distribution
.Solver
.Types
.ConstraintSource
(ConstraintSource
(..))
20 import Distribution
.Client
.ProjectFlags
25 import Distribution
.Client
.Setup
38 data NixStyleFlags a
= NixStyleFlags
39 { configFlags
:: ConfigFlags
40 , configExFlags
:: ConfigExFlags
41 , installFlags
:: InstallFlags
42 , haddockFlags
:: HaddockFlags
43 , testFlags
:: TestFlags
44 , benchmarkFlags
:: BenchmarkFlags
45 , projectFlags
:: ProjectFlags
50 :: (ShowOrParseArgs
-> [OptionField a
])
52 -> [OptionField
(NixStyleFlags a
)]
53 nixStyleOptions commandOptions showOrParseArgs
=
57 -- Note: [Hidden Flags]
58 -- We reuse the configure options from v1 commands which on their turn
59 -- reuse the ones from Cabal) but we hide some of them in v2 commands.
65 , "promised-dependency"
66 , "exact-configuration"
71 $ configureOptions showOrParseArgs
78 ConstraintSourceCommandlineFlag
83 -- hide "target-package-db" and "symlink-bindir" flags from the
85 -- "symlink-bindir" is obsoleted by "installdir" in ClientInstallFlags
87 ( (`
notElem`
["target-package-db", "symlink-bindir"])
90 $ installOptions showOrParseArgs
95 -- hide "verbose" and "builddir" flags from the
98 ( (`
notElem`
["v", "verbose", "builddir"])
101 $ haddockOptions showOrParseArgs
103 ++ liftOptions testFlags set5
(testOptions showOrParseArgs
)
104 ++ liftOptions benchmarkFlags set6
(benchmarkOptions showOrParseArgs
)
105 ++ liftOptions projectFlags set7
(projectFlagsOptions showOrParseArgs
)
106 ++ liftOptions extraFlags set8
(commandOptions showOrParseArgs
)
108 set1 x flags
= flags
{configFlags
= x
}
109 set2 x flags
= flags
{configExFlags
= x
}
110 set3 x flags
= flags
{installFlags
= x
}
111 set4 x flags
= flags
{haddockFlags
= x
}
112 set5 x flags
= flags
{testFlags
= x
}
113 set6 x flags
= flags
{benchmarkFlags
= x
}
114 set7 x flags
= flags
{projectFlags
= x
}
115 set8 x flags
= flags
{extraFlags
= x
}
117 defaultNixStyleFlags
:: a
-> NixStyleFlags a
118 defaultNixStyleFlags x
=
120 { configFlags
= mempty
121 , configExFlags
= mempty
122 , installFlags
= mempty
123 , haddockFlags
= mempty
125 , benchmarkFlags
= mempty
126 , projectFlags
= defaultProjectFlags