[Nix-dev] Installing a Haskell program
Arseniy Seroka
ars.seroka at gmail.com
Sun May 17 01:23:52 CEST 2015
My usual haskell workflow is
```
$ cabal2nix ./. --shell > shell.nix
$ cabal2nix ./. > project.nix
$ # I have file default.nix [1] in project too
$ nix-shell # going into shell to use vim, ghc-mod etc
$ nix-build # building my project, usually doing that in parallel to vim
$ ./result/bin/foobar # testing my executable
```
[1] `pkgs ? import <nixpkgs> {} }: pkgs.haskellngPackages.callPackage
./project.nix {}`
2015-05-17 2:10 GMT+03:00 Amy de Buitléir <amy at nualeargais.ie>:
> I have a very simple Haskell project, with just two files, Jot.cabal and
> Jot.hs. I can build and run it OK, but can't figure out how to install it.
>
> [amy at wombat9000:~/jot]$ cabal2nix --shell . > default.nix
>
> [amy at wombat9000:~/jot]$ nix-shell -I ~ --command 'cabal configure'
> Warning: The package list for 'hackage.haskell.org' does not exist.
> Run
> 'cabal
> update' to download it.
> Resolving dependencies...
> Configuring Jot-1.0...
>
> NOTE: I didn't run 'cabal update'. I'm guessing that I don't need to
> because
> haskell NG is managing haskell packages for me.
>
> [amy at wombat9000:~/jot]$ cabal build
> Building Jot-1.0...
> Preprocessing executable 'jot' for Jot-1.0...
> [1 of 1] Compiling Main ( Jot.hs,
> dist/build/jot/jot-tmp/Main.o )
> Linking dist/build/jot/jot ...
>
> [amy at wombat9000:~/jot]$ cabal run
>
> ...it works fine. So now I want to install it so I can run the "jot"
> command
> anywhere on my system. I created a shell.nix file:
>
> [amy at wombat9000:~/jot]$ cat shell.nix
> { pkgs ? (import <nixpkgs> {}) }:
>
> (import ./default.nix) {
> stdenv = pkgs.stdenv;
> haskellngPackages = pkgs.haskellngPackages;
> }
>
> [amy at wombat9000:~/jot]$ nix-env -f default.nix -i
> installing ‘interactive-Jot-1.0-environment’
> these derivations will be built:
>
>
> /nix/store/1nwq9hcna1j1pcinp41xlxysqzd3m7bh-interactive-Jot-1.0-environment.drv
> building path(s)
>
> ‘/nix/store/svkd0dh83fs2rr1p18zbq1ldcnx0xz1w-interactive-Jot-1.0-environment’
> unpacking sources
> variable $src or $srcs should point to the source
> builder for
>
> ‘/nix/store/1nwq9hcna1j1pcinp41xlxysqzd3m7bh-interactive-Jot-1.0-environment.drv’
> failed with exit code 1
> error: build of
>
> ‘/nix/store/1nwq9hcna1j1pcinp41xlxysqzd3m7bh-interactive-Jot-1.0-environment.drv’
> failed
>
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
--
Sincerely,
Arseniy Seroka
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20150517/3bf276e0/attachment-0001.html
More information about the nix-dev
mailing list