├── LICENSE ├── README.md └── nix-cabal /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Vladislav Zavialov 2 | 2018, Monadfix 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials provided 15 | with the distribution. 16 | 17 | * Neither the name of Monadfix nor the names of other 18 | contributors may be used to endorse or promote products derived 19 | from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nix-cabal 2 | 3 | ![nix-logo](https://user-images.githubusercontent.com/4061728/48418536-978bc480-e766-11e8-9206-44292ea5e0f1.png) ![cabal-logo](https://user-images.githubusercontent.com/4061728/48418551-a07c9600-e766-11e8-9b47-a6497986936d.png) 4 | 5 | This is a small wrapper script to run `cabal` inside `nix-shell`. It assumes 6 | `shell.nix` to be present in the current directory. 7 | 8 | ## Installation 9 | 10 | Download the script to a location of your choice, for instance 11 | `$HOME/.local/bin/`, and make it executable: 12 | 13 | ```bash 14 | curl https://raw.githubusercontent.com/monadfix/nix-cabal/master/nix-cabal -o $HOME/.local/bin/nix-cabal 15 | chmod u+x $HOME/.local/bin/nix-cabal 16 | ``` 17 | 18 | Make sure this location is in your `$PATH`. 19 | 20 | ## Usage 21 | 22 | ```bash 23 | nix-cabal v2-build all 24 | ``` 25 | 26 | Here's an example of a `shell.nix` you might want to use with this script: 27 | 28 | ```nix 29 | { 30 | pkgs ? import {}, 31 | hc ? "ghc844" 32 | }: 33 | 34 | pkgs.stdenv.mkDerivation rec { 35 | name = "example"; 36 | buildInputs = [ 37 | pkgs.haskell.compiler.${hc} 38 | pkgs.git 39 | pkgs.zlib 40 | pkgs.cabal-install 41 | pkgs.pkgconfig 42 | pkgs.which 43 | ]; 44 | shellHook = '' 45 | export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath buildInputs}:$LD_LIBRARY_PATH 46 | export LANG=en_US.UTF-8 47 | ''; 48 | LOCALE_ARCHIVE = 49 | if pkgs.stdenv.isLinux 50 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" 51 | else ""; 52 | } 53 | ``` 54 | 55 | ## Travis CI 56 | 57 | Here's an example of a `.travis.yml`: 58 | 59 | ```yaml 60 | language: nix 61 | 62 | os: 63 | - linux 64 | - osx 65 | 66 | env: 67 | - HC=ghc822 68 | - HC=ghc844 69 | - HC=ghc861 70 | 71 | before_install: 72 | - curl https://raw.githubusercontent.com/monadfix/nix-cabal/master/nix-cabal -o nix-cabal && chmod u+x nix-cabal 73 | - travis_retry ./nix-cabal v2-update 74 | 75 | script: 76 | - ./nix-cabal v2-test 77 | - ./nix-cabal v2-bench 78 | 79 | cache: 80 | directories: 81 | - ~/.cabal 82 | - ~/.ghc 83 | ``` 84 | -------------------------------------------------------------------------------- /nix-cabal: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [ -z "$HC" ]; then 6 | ARG_HC="" 7 | else 8 | ARG_HC="--argstr hc $HC" 9 | fi 10 | 11 | CMD="cabal $@" 12 | nix-shell --pure $ARG_HC --run "$CMD" 13 | --------------------------------------------------------------------------------