https://github.com/composewell/streamly-packages
A nix-shell derivation for streamly ecosystem packages
https://github.com/composewell/streamly-packages
Last synced: 2 months ago
JSON representation
A nix-shell derivation for streamly ecosystem packages
- Host: GitHub
- URL: https://github.com/composewell/streamly-packages
- Owner: composewell
- Created: 2022-11-23T12:36:51.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-11T11:03:07.000Z (over 1 year ago)
- Last Synced: 2025-01-18T05:33:48.343Z (over 1 year ago)
- Language: Nix
- Size: 65.4 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nix Shell for Haskell Development
A ready-to-use Nix shell environment tailored for Haskell, having
Haskell Streamly and its ecosystem packages installed out of the
box. Easily customizable to include any package from Hackage.
**Includes:**
* `nvim`: Stylish Vim IDE with plugins
* `codium`: Visual Studio Code with extensions
* `ghc`: the Haskell compiler
* `cabal`: the Haskell project build tool
* HLS: the Haskell language server
* Hoogle server for searchable documentation
* Essential Haskell development tools
* Streamly ecosystem libraries
The version of `nixpkgs` can be changed in the [default.nix](default.nix) or
[flake.nix](flake.nix) files whichever you use.
Please refer to
[this page](https://haskell-language-server.readthedocs.io/en/latest/features.html)
for Haskell language server features.
# Starting the Shell
There are two ways to start the nix shell.
## Directly using github URL
To get a shell with the development environment installed in it, use the
following command:
```
nix-shell https://github.com/composewell/streamly-packages/archive/master.tar.gz
```
If it takes too long to build the hoogle file you can disable hoogle:
```
nix-shell --arg hoogle false ...
```
Use the cloning method if you would like to customize the environment
before using. For example, if it is using too much space
installing packages that you do not need.
## By cloning the github repo
You can clone the `streamly-packages` repo and run `nix-shell`
command from the repo root directory.
```
git clone https://github.com/composewell/streamly-packages
cd streamly-packages
nix-shell
```
You can comment out any packages you do not need in
[packages.nix](packages.nix).
# Using the Shell
Once you are in the shell, you can use `ghc`, `cabal`, `nvim`, `codium`,
`hoogle`, and other CLI tools from the PATH. Essential streamly packages
are pre-installed in the `ghc` package database, ready to use.
To start with, you can try building and running the examples from the
[streamly-examples](https://github.com/composewell/streamly-examples/tree/v0.3.0/examples)
package.
Alternatively, you can start the interactive repl `ghci` and play with Haskell
code interactively.
# Show installed packages
To show the Haskell packages that are already installed in the shell,
run the following command in the nix shell:
```
ghc-pkg list
```
# Building a Haskell Package
We do not depend on cabal to download and build the dependencies.
Instead add your project dependencies in the library section of
[packages.nix](packages.nix), any package specified here and all its
dependencies are pre-installed in the shell from nixpkgs.
For example to build the streamly-examples package:
```
git clone https://github.com/composewell/streamly-examples
cd streamly-examples
cabal build
```
# Overriding package versions
To override or update the versions of Haskell packages used, edit the
[sources.nix](sources.nix) file to specify
particular git commit ids or package versions from hackage to be used.
# Adding your own packages
If you need any additional packages in this environment just add
them to the list of packages in [packages.nix](packages.nix).
# Accessing the documentation
Inside the nix shell, run the following command:
```
hoogle server --local -p 8080
```
Open the URL `http://127.0.0.1:8080` in your browser.
# Using vim editor
Inside the nix shell, run the following command:
```
nvim
```
Use `ESC :q` to quit.
Use `,h` for help.
Use `:colorscheme morning` if you want a light theme.
Add the following to your `$HOME/.config/nvim/coc-settings.json` to use the
haskell language server with nvim:
```
{
"languageserver": {
"haskell": {
"command": "haskell-language-server-wrapper",
"args": ["--lsp"],
"rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"],
"filetypes": ["haskell", "lhaskell"],
"settings": {
"haskell": {
"checkParents": "CheckOnSave",
"checkProject": true,
"formattingProvider": "fourmolu"
}
}
}
}
}
```
To customize vim plugins see
[nixpack-editors](https://github.com/composewell/nixpack-editors), fork
and edit that repo and change its git URL in [packages.nix](package.nix).
# Using VSCode editor
To run VSCodium, the open source version of Microsoft VSCode, run the
following command in the nix-shell:
```
codium
```
If you have started the nix-shell with `haskell-tools` included, you
will have the Haskell Language Server installed in the shell. If you
get a pop up saying: "How do you want the extension to manage/discover
HLS and the relevant toolchain?" just choose, "Manually via PATH".
You can also set it later in the following section in settings:
* Extensions
* Haskell
* Manage HLS
* PATH
If you wish to use your existing installation of VSCode instead of
`codium` from the nix-shell, you can do that too, just make sure to run
it from within the nix-shell so that it is able to use the installed
Haskell tools and libraries. For example, on MacOS, if you have your
vscode app in `Downloads` folder:
```
open ~/Downloads/Visual\ Studio\ Code.app
```
To customize vscode extensions see
[nixpack-editors](https://github.com/composewell/nixpack-editors), fork
and edit that repo and change its git URL in [packages.nix](package.nix).