| | 245 | |
| | 246 | == sandbox command == |
| | 247 | |
| | 248 | |
| | 249 | Sandboxes are created, inspected, modified, and deleted through the |
| | 250 | `cabal sandox` command: |
| | 251 | |
| | 252 | * `cabal sandbox init` creates a new sandbox. |
| | 253 | |
| | 254 | * `cabal sandbox delete` deleted the sandbox, including all packages |
| | 255 | installed in the sandbox (i.e. in `.cabal-sandbox`). |
| | 256 | |
| | 257 | * `cabal sandbox add-source` adds a source package to the sandbox |
| | 258 | package database. |
| | 259 | |
| | 260 | * In the future we might add commands for showing the packages |
| | 261 | installed in the sandbox, the sandbox location (i.e. directory), |
| | 262 | etc. |
| | 263 | |
| | 264 | `sandbox init` creates a new sandbox by creating a specially named |
| | 265 | file, `cabal.sandbox.config`, in the root directory of the package. |
| | 266 | This file contains a `local-repo` and a `install-dirs` `prefix` that |
| | 267 | points to the sandbox (i.e. to `.cabal-sandbox/packages` and |
| | 268 | `.cabal-sandbox` respectively). If this file is present, all builds in |
| | 269 | the package's directory will use the sandbox. |
| | 270 | |
| | 271 | The `cabal.sandbox.config` file is not normally edited by users and |
| | 272 | should contain a warning on top of the file saying that it's machine |
| | 273 | generated. If the user wants to add e.g. package constraints she |
| | 274 | should use the (new) `cabal.config` file, which doesn't exist by |
| | 275 | default but can be added to the package's root directory by the user. |
| | 276 | |
| | 277 | By using two different package environment files (both recognized by |
| | 278 | Cabal through their special names) allows us to have one file that the |
| | 279 | user can edit without worrying about the system overwriting any |
| | 280 | changes she made (including comments and whitespace layout). |
| | 281 | |
| | 282 | Even though the `cabal.sandbox.config` file is normally not edited by |
| | 283 | the user we decided to keep it visible (i.e. not in `.cabal-sandbox`) |
| | 284 | so the user can edit it if desired. We can revisit this choice in the |
| | 285 | future if this proves to confuse users. |
| | 286 | |
| | 287 | The config files have the following priorities, from higher to lower: |
| | 288 | |
| | 289 | 1. `cabal.sandbox.config` |
| | 290 | 2. `cabal.config` |
| | 291 | 3. `~/.cabal/config` |
| | 292 | |
| | 293 | Once a sandbox have been created, all cabal commands (e.g. configure, |
| | 294 | build, and install) will make use of it automatically. |
| | 295 | |
| | 296 | Source packages that have been added ("linked") into the sandbox by |
| | 297 | `add-source` are rebuilt (and reconfigured, if needed) and installed |
| | 298 | into the sandbox each time the main package is built. We most likely |
| | 299 | want to optimize this process some time in the future, to avoid |
| | 300 | rebuilding/relinkining when neccesary. |