0 | module Pack.Config.TOML
5 | import Pack.Config.Types
14 | FromTOML Autoload where
15 | fromTOML dir v = case v of
16 | TStr "none" => Right NoPkgs
17 | TStr "installed" => Right Installed
18 | TStr "autolibs" => Right AutoLibs
19 | _ => AutoPkgs <$> fromTOML dir v
22 | FromTOML Codegen where
23 | fromTOML = tmap Types.fromString
25 | extractString : (errMsg : String) -> (v : TomlValue) -> Either TOMLErr String
26 | extractString _ (TStr s) = Right s
27 | extractString errMsg _ = Left $
WrongType [] errMsg
30 | FromTOML RlwrapConfig where
31 | fromTOML _ (TBool x) = Right $
if x then UseRlwrap [] else DoNotUseRlwrap
32 | fromTOML _ (TStr str) = Right $
UseRlwrap [NoEscape str]
33 | fromTOML _ (TArr xs) =
34 | map (UseRlwrap . fromStrList) $
35 | traverse (extractString "array of strings") xs
36 | fromTOML _ _ = Left $
WrongType [] "boolean, string or array of strings"
39 | FromTOML CmdArgList where
40 | fromTOML _ (TStr str) = Right $
[NoEscape str]
41 | fromTOML _ (TArr xs) =
43 | traverse (extractString "array of strings") xs
44 | fromTOML _ _ = Left $
WrongType [] "string or array of strings"
47 | FromTOML UserConfig where
50 | (maybeValAt "collection" f v)
51 | (maybeValAt "idris2.url" f v)
52 | (maybeValAt "idris2.commit" f v)
53 | (toList <$> maybeValAt "idris2.commit" f v)
54 | (maybeValAt "pack.url" f v)
55 | (maybeValAt "pack.commit" f v)
56 | (maybeValAt "idris2.scheme" f v)
57 | (maybeValAt "idris2.bootstrap" f v)
58 | (maybeValAt "idris2.bootstrap-stage3" f v)
59 | (maybeValAt "install.safety-prompt" f v)
60 | (maybeValAt "install.gc-prompt" f v)
61 | (maybeValAt "install.gc-purge" f v)
62 | (maybeValAt "install.warn-depends" f v)
63 | (maybeValAt "admin.skip-tests" f v)
64 | (maybeValAt "install.whitelist" f v)
65 | (maybeValAt "install.with-src" f v)
66 | (maybeValAt "install.with-docs" f v)
67 | (maybeValAt "install.use-katla" f v)
69 | (maybeValAt "idris2.repl.rlwrap" f v)
70 | (maybeValAt "idris2.extra-args" f v)
71 | (maybeValAt "install.libs" f v)
72 | (maybeValAt "install.apps" f v)
73 | (maybeValAt "idris2.repl.autoload" f v)
74 | (maybeValAt "custom" f v)
77 | (maybeValAt "idris2.codegen" f v)
79 | (maybeValAt "log" f v)
80 | (maybeValAt "idris2.git" f v)
85 | initToml : (scheme : String) -> String
86 | initToml scheme = """
89 | # Whether to install packages together with their
90 | # sources or not. This is mainly useful for programmers
91 | # who have set their editor up with some *go to definition*
92 | # functionality (for instance by using idris2-lsp with neovim).
95 | # Whether to install API docs together with installed
99 | # Whether to use katla to generate HTML links to
100 | # semantically highlighted API sources
101 | # use-katla = false
103 | # Whether to prompt the user before building or installing
104 | # packages or applications with custom build hooks in their
106 | # safety-prompt = true
108 | # Whether to prompt the user before running the garbage collector
109 | # via command `gc`.
112 | # Whether to remove all outdated libraries and applications during
113 | # garbage collection (command `gc`).
116 | # Whether to issue a warning in presence of a local `depends` directory
117 | # which might interfere with the libraries managed by pack
118 | # warn-depends = true
120 | # List of packages and apps with custom build hooks we trust to
121 | # be safe. This gives more fine grained control over package safety
122 | # than `safety-prompt`.
123 | # whitelist = [ "pack", "idris2-lsp" ]
125 | # Must-have libraries. These will be installed automatically
126 | # when using a new package collection.
127 | # Example: `libs = [ "toml", "elab-util" ]`
130 | # Must-have applications. These will be installed automatically
131 | # when using a new package collection.
132 | # Example: `apps = [ "idris2-lsp" ]`
137 | # Override this to use a custom Git repo for pack
138 | # url = "https://github.com/stefan-hoeck/idris2-pack"
140 | # Override this to use a custom commit and branch for pack
141 | # commit = "latest:main"
145 | # Whether to build Idris2 with its bootstrap compiler.
146 | # Bootstrapping takes longer than building with an existing
147 | # Idris2 installation, but it will work even if the existing
148 | # Idris2 compiler is outdated.
149 | # bootstrap = false
151 | # Whether to rebuild Idris2 when bootstrapping, using the newly
152 | # built compiler. Produces a more optimised final executable,
153 | # but increases build time.
154 | # bootstrap-stage3 = true
156 | # Name or path to the scheme executable to use.
157 | scheme = "\{scheme}"
159 | # Default code generator to us
162 | # Set this to `true` in order to run REPL sessions from within
163 | # `rlwrap`. This will give you additional features such as a
165 | # Alternatively, you can pass additional command-line arguments
166 | # to `rlwrap` by setting this to a string or an array of strings,
167 | # e.g. to "-pGreen -aN" or ["-pGreen", "--no-children"].
168 | # repl.rlwrap = false
170 | # Packages to load automatically when starting a REPL session
171 | # without an `.ipkg` file in scope. This defaults to "none".
172 | # Note: Uncomment only one of the following examples:
173 | # repl.autoload = "installed"
174 | # repl.autoload = "autolibs"
175 | # repl.autoload = [ "sop", "toml" ]
177 | # Override this to use a custom Git repo for the Idris compiler
178 | # url = "https://github.com/idris-lang/Idris2"
180 | # Override this to use a custom commit and branch for the Idris compiler
181 | # commit = "latest:main"
183 | # Override this to have a .gitignore file and .git directory
184 | # created inside of a new pack project upon its creation.
187 | # Additional arguments to be passed to the Idris compiler
188 | # This can be a single string or a list of strings.
191 | # Below are some examples for custom packages
193 | # A local package to be available with all
194 | # package collections. The path to the package's root
195 | # directory can be absolute or relative. In the latter
196 | # case, it will be considered to be relative to the
197 | # parent directory of the `pack.toml` file where it is
200 | # The path to `.ipkg` files must always relative to the
202 | # [custom.all.chem]
204 | # path = "/data/idris/chem"
205 | # ipkg = "chem.ipkg"
207 | # A package as a Git repository to be available with all
208 | # package collections.
211 | # url = "https://github.com/bar/foo"
212 | # commit = "commit-ref"
213 | # ipkg = "foo.ipkg"
215 | # Override library `toml` from package collection `nightly-220503`
216 | # by using a custom commit hash.
217 | # [custom.nightly-251023.ilex]
219 | # url = "https://github.com/stefan-hoeck/idirs2-ilex"
220 | # commit = "eb7a146f565276f82ebf30cb6d5502e9f65dcc3c"
221 | # ipkg = "ilex.ipkg"
223 | # Uncomment and adjust the following entries to specify the
224 | # default log level associated with each pack command.
225 | # Possible log levels are:
235 | # install-deps = "build"
236 | # typecheck = "build"
238 | # cleanbuild = "build"
241 | # install = "build"
242 | # install-app = "build"
244 | # remove-app = "build"
250 | # package-path = "silence"
251 | # libs-path = "silence"
252 | # data-path = "silence"
253 | # app-path = "silence"
255 | # update-db = "build"
260 | # completion = "silence"
261 | # completion-script = "silence"
262 | # uninstall = "info"