Add nix files
generated via:
$ cabal2nix ./ >default.nix
$ cabal2nix --shell ./ >shell.nix
### Not testet yet!
I will make a comment once I have tested them
@maximilianhuber did you test yet?
No, not yet, sorry. Still the same problems with the nixos+cabal setup due to the usage of the homedir by another OS.
Testing nix-shell:
$ nix-shell [nix-shell:~vgrep]$ stack build dlist-0.7.1.2: using precompiled package data-default-class-0.0.1: using precompiled package [...] Registering vgrep-0.2.0.0... Completed 60 action(s). [nix-shell:~vgrep]$ stack exec vgrep test ./
works for me
It should not matter for stack whether or not you are in a nix-shell: The correct ghc version is fetched via Nix (when --nix is given), but the dependencies are fetched and compiled by stack itself.
That said, I just tried
> nix-build shell.nix
…
these derivations will be built:
/nix/store/ks711vnkl5bj7bb9x749ns02yyzzxm3f-vgrep-0.2.0.0.drv
building path(s) ‘/nix/store/x5l3ah5mxfxradrl6im6rlimx2i42xrd-vgrep-0.2.0.0’
…
installing
Installing library in
/nix/store/x5l3ah5mxfxradrl6im6rlimx2i42xrd-vgrep-0.2.0.0/lib/ghc-8.0.1/vgrep-0.2.0.0
Installing executable(s) in
/nix/store/x5l3ah5mxfxradrl6im6rlimx2i42xrd-vgrep-0.2.0.0/bin
Warning: The directory
/nix/store/x5l3ah5mxfxradrl6im6rlimx2i42xrd-vgrep-0.2.0.0/bin is not in the
system search path.
Creating package registration file:
/nix/store/x5l3ah5mxfxradrl6im6rlimx2i42xrd-vgrep-0.2.0.0/lib/ghc-8.0.1/package.conf.d/vgrep-0.2.0.0.conf
…
patching script interpreter paths in /nix/store/x5l3ah5mxfxradrl6im6rlimx2i42xrd-vgrep-0.2.0.0
/nix/store/x5l3ah5mxfxradrl6im6rlimx2i42xrd-vgrep-0.2.0.0
which does what it should do.
I'm a bit torn: On one hand, this enables Nix users to build vgrep from source using Nix, without having to install stack (and without having to wait until lens is compiled). On the other hand, this poses extra maintenance, and room for errors (like forgetting to bump the version number…).
And after all, generating these two files is a simple nix-shell -p cabal2nix --run 'cabal2nix . > default.nix; cabal2nix --shell . > shell.nix' away. So I think it would be worth considering to either add a build manual for Nix to the README.md file, or a nix-setup script that generates these files?
This is a minimal script for generating default.nix and shell.nix:
#!/usr/bin/env nix-shell
#! nix-shell -p cabal2nix -i bash
cabal2nix . > default.nix
cabal2nix --shell . > shell.nix
I have modified the README and removed the nix files