forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNixParser.hs
More file actions
71 lines (68 loc) · 2.33 KB
/
NixParser.hs
File metadata and controls
71 lines (68 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{-# LANGUAGE NoImplicitPrelude #-}
module Stack.Options.NixParser
( nixOptsParser
) where
import qualified Data.Text as T
import Options.Applicative
( Parser, completer, help, long, metavar, option, str )
import Options.Applicative.Args ( argsOption )
import Options.Applicative.Builder.Extra
( fileExtCompleter, firstBoolFlagsFalse
, firstBoolFlagsNoDefault, optionalFirst
)
import Stack.Nix ( nixCmdName )
import Stack.Options.Utils ( hideMods )
import Stack.Prelude
import Stack.Types.Nix ( NixOptsMonoid (..) )
nixOptsParser :: Bool -> Parser NixOptsMonoid
nixOptsParser hide0 = overrideActivation <$>
( NixOptsMonoid
<$> firstBoolFlagsNoDefault
nixCmdName
"use of a Nix-shell. Implies 'system-ghc: true'."
hide
<*> firstBoolFlagsNoDefault
"nix-pure"
"use of a pure Nix-shell. Implies '--nix' and 'system-ghc: true'."
hide
<*> optionalFirst (textArgsOption
( long "nix-packages"
<> metavar "NAMES"
<> help "List of packages that should be available in the nix-shell \
\(space separated)."
<> hide
))
<*> optionalFirst (option str
( long "nix-shell-file"
<> metavar "FILE"
<> completer (fileExtCompleter [".nix"])
<> help "Nix file to be used to launch a nix-shell (for regular Nix \
\users)."
<> hide
))
<*> optionalFirst (textArgsOption
( long "nix-shell-options"
<> metavar "OPTIONS"
<> help "Additional options passed to nix-shell."
<> hide
))
<*> optionalFirst (textArgsOption
( long "nix-path"
<> metavar "PATH_OPTIONS"
<> help "Additional options to override NIX_PATH parts (notably \
\'nixpkgs')."
<> hide
))
<*> firstBoolFlagsFalse
"nix-add-gc-roots"
"addition of packages to the nix GC roots so nix-collect-garbage does \
\not remove them."
hide
)
where
hide = hideMods hide0
overrideActivation m =
if fromFirst False (nixMonoidPureShell m)
then m { nixMonoidEnable = (First . Just . fromFirst True) (nixMonoidEnable m) }
else m
textArgsOption = fmap (map T.pack) . argsOption