https://github.com/monadfix/nix-cabal
Run cabal inside nix-shell
https://github.com/monadfix/nix-cabal
cabal-install haskell nix
Last synced: 10 months ago
JSON representation
Run cabal inside nix-shell
- Host: GitHub
- URL: https://github.com/monadfix/nix-cabal
- Owner: monadfix
- License: other
- Created: 2018-11-13T12:41:13.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-26T17:35:02.000Z (over 6 years ago)
- Last Synced: 2025-03-22T07:43:23.655Z (10 months ago)
- Topics: cabal-install, haskell, nix
- Language: Shell
- Homepage:
- Size: 2.93 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nix-cabal
 
This is a small wrapper script to run `cabal` inside `nix-shell`. It assumes
`shell.nix` to be present in the current directory.
## Installation
Download the script to a location of your choice, for instance
`$HOME/.local/bin/`, and make it executable:
```bash
curl https://raw.githubusercontent.com/monadfix/nix-cabal/master/nix-cabal -o $HOME/.local/bin/nix-cabal
chmod u+x $HOME/.local/bin/nix-cabal
```
Make sure this location is in your `$PATH`.
## Usage
```bash
nix-cabal v2-build all
```
Here's an example of a `shell.nix` you might want to use with this script:
```nix
{
pkgs ? import {},
hc ? "ghc844"
}:
pkgs.stdenv.mkDerivation rec {
name = "example";
buildInputs = [
pkgs.haskell.compiler.${hc}
pkgs.git
pkgs.zlib
pkgs.cabal-install
pkgs.pkgconfig
pkgs.which
];
shellHook = ''
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath buildInputs}:$LD_LIBRARY_PATH
export LANG=en_US.UTF-8
'';
LOCALE_ARCHIVE =
if pkgs.stdenv.isLinux
then "${pkgs.glibcLocales}/lib/locale/locale-archive"
else "";
}
```
## Travis CI
Here's an example of a `.travis.yml`:
```yaml
language: nix
os:
- linux
- osx
env:
- HC=ghc822
- HC=ghc844
- HC=ghc861
before_install:
- curl https://raw.githubusercontent.com/monadfix/nix-cabal/master/nix-cabal -o nix-cabal && chmod u+x nix-cabal
- travis_retry ./nix-cabal v2-update
script:
- ./nix-cabal v2-test
- ./nix-cabal v2-bench
cache:
directories:
- ~/.cabal
- ~/.ghc
```