Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to build with stack build --nix on NixOS #253

Closed
ethercrow opened this issue Jun 28, 2016 · 6 comments
Closed

Failure to build with stack build --nix on NixOS #253

ethercrow opened this issue Jun 28, 2016 · 6 comments

Comments

@ethercrow
Copy link

ihaskell-inline-r-0.1.1.0: configure
ihaskell-inline-r-0.1.1.0: build

--  While building package ihaskell-inline-r-0.1.1.0 using:
      /home/ethercrow/.stack/setup-exe-cache/x86_64-linux-nix/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-1.22.5.0 build lib:ihaskell-inline-r --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/ethercrow/src/HaskellR/.stack-work/logs/ihaskell-inline-r-0.1.1.0.log

    Configuring ihaskell-inline-r-0.1.1.0...
    Preprocessing library ihaskell-inline-r-0.1.1.0...
    [1 of 1] Compiling IHaskell.Display.InlineR ( src/IHaskell/Display/InlineR.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.22.5.0/build/IHaskell/Display/InlineR.o )
    <command line>: can't load .so/.DLL for: libncursesw.so (libncursesw.so: cannot open shared object file: No such file or directory)

Is this related: https://ghc.haskell.org/trac/ghc/ticket/11042?

@mboes
Copy link
Member

mboes commented Jun 28, 2016

It is indeed. @YPares we need Stack to restore the LD_LIBRARY_PATH workaround which I believe was there at some point. i.e. match what the haskell.lib.buildStackProject function from Nixpkgs does.

@ethercrow you can work around this by using an explicit shell file. Uncomment the shell-file: line in the stack.yaml. And if you're using Nixpkgs unstable then amend the shell file to include a ghc argument as documented here: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/haskell.md#how-to-build-a-haskell-project-using-stack.

@ethercrow
Copy link
Author

Commenting packages and uncommenting shell-file results in:

~/src/HaskellR master*  
> stack build --nix
error: infinite recursion encountered, at /nix/store/z21asrspz2nc471jzjg4kc68lxv38288-nixos/nixos/pkgs/development/haskell-modules/generic-stack-builder.nix:8:9
(use ‘--show-trace’ to show detailed location information)

I use nixos-unstable channel, so I've tried this amendment you pointed at:

--- a/shell.nix
+++ b/shell.nix
@@ -2,7 +2,9 @@
 # the --enable-strict-barrier configure flag enabled for better memory
 # diagnostics.

-with (import <nixpkgs> { });
+{nixpkgs ? import <nixpkgs> { }, ghc ? nixpkgs.ghc}
+
+import nixpkgs;

 with stdenv.lib;

This results in the following error:

> stack build --nix               
error: syntax error, unexpected ID, expecting ':' or '@', at /home/ethercrow/src/HaskellR/shell.nix:7:1

@mboes
Copy link
Member

mboes commented Jun 29, 2016

You missed a ::

+{nixpkgs ? import <nixpkgs> { }, ghc ? nixpkgs.ghc}:

Also, you're getting the "infinite recursion" because your patch doesn't include the inherit ghc line in the body of the argument to haskell.lib.buildStackProject. See the doc I linked to previously.

@ethercrow
Copy link
Author

The doc doesn't have the :. My bad about missing inherit ghc. Still failing though:

~/src/HaskellR master*  
> git diff shell.nix 
diff --git a/shell.nix b/shell.nix
index 5096c02..18d0906 100644
--- a/shell.nix
+++ b/shell.nix
@@ -2,7 +2,9 @@
 # the --enable-strict-barrier configure flag enabled for better memory
 # diagnostics.

-with (import <nixpkgs> { });
+{nixpkgs ? import <nixpkgs> { }, ghc ? nixpkgs.ghc}:
+
+import nixpkgs;

 with stdenv.lib;

@@ -14,4 +16,5 @@ haskell.lib.buildStackProject {
   name = "HaskellR";
   buildInputs = [ ncurses pkgconfig python34Packages.ipython R zeromq zlib ];
   LANG = "en_US.UTF-8";
+  inherit ghc;
 }

~/src/HaskellR master*  
> stack build --nix 
error: syntax error, unexpected ';', expecting $end, at /home/ethercrow/src/HaskellR/shell.nix:7:15

@ethercrow
Copy link
Author

I was able to get build working with this shell-file patch:

diff --git a/shell.nix b/shell.nix
index 5096c02..76a64a9 100644
--- a/shell.nix
+++ b/shell.nix
@@ -2,16 +2,20 @@
 # the --enable-strict-barrier configure flag enabled for better memory
 # diagnostics.

-with (import <nixpkgs> { });
+{ pkgs ? import <nixpkgs> {} }:

-with stdenv.lib;
+with pkgs;

 let
   R = pkgs.R.override { enableStrictBarrier = true; };
 in

-haskell.lib.buildStackProject {
+stdenv.mkDerivation {
   name = "HaskellR";
-  buildInputs = [ ncurses pkgconfig python34Packages.ipython R zeromq zlib ];
-  LANG = "en_US.UTF-8";
-}
+
+  buildInputs = [ ncurses.out ncurses.dev pkgconfig python34Packages.ipython R zeromq zlib.out haskell.compiler.ghc7103 ];
+
+  shellHook = ''
+    export LD_LIBRARY_PATH="${ncurses.out}/lib:${zlib.out}/lib:$LD_LIBRARY_PATH"
+  '';
+}

@mboes
Copy link
Member

mboes commented Sep 4, 2016

Fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants