Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aycanirican/nixit

Build my haskell project using nix
https://github.com/aycanirican/nixit

cabal cabal2nix haskell hpack nix stack

Last synced: 18 days ago
JSON representation

Build my haskell project using nix

Awesome Lists containing this project

README

        

# nixit

Build my haskell executable using nix.

## Usage

- You are in your project's directory
```
cd $TMP
mkdir project1; cd project1
```

- You have a proper `Main.hs` file like this:
```
module Main where

main :: IO ()
main = print "5 more minutes...Done."
```
- Optionally you write all haskell dependencies (one for each line)
in a file `.nixit.deps` like:
```
aeson
servant-client
lens
```

Then you can have your executable with:
```
nix build -f https://github.com/aycanirican/nixit/archive/master.tar.gz \
--arg src "$PWD" \
--argstr deps "$(cat .nixit.deps | xargs)"
```

And also you can have a ghci session with:
```
nix-shell -p "pkgs.haskellPackages.ghcWithPackages (p: with p; [ $(cat .nixit.deps | xargs) ])" \
--command "ghci Main.hs"
```

Or if you want to just execute ghcid and watch it recompiling your project:
```
nix-shell -p "pkgs.haskellPackages.ghcWithPackages (p: with p; [ $(cat .nixit.deps | xargs) ])" \
-p haskellPackages.ghcid \
--command "ghcid --command \"ghci Main.hs\""
```

Or you may want to stick on a release:
```
NIX_PATH=nixpkgs=https://nixos.org/channels/nixos-19.09/nixexprs.tar.xz \
nix-shell -p "pkgs.haskellPackages.ghcWithPackages (p: with p; [ $(cat .nixit.deps | xargs) ])" --command "ghci Main.hs"
```