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

Setup stack's nix integration #63

Merged
merged 5 commits into from
Nov 7, 2019
Merged

Conversation

alexfmpe
Copy link
Contributor

https://docs.haskellstack.org/en/stable/nix_integration/
Doesn't actually solve #3 (#53 will probably take a while to finish), but it does allow nix to handle non-haskell dependencies which allows the stack build to work on NixOS.
I left the nix integration disabled by default on non-NixOS, but it can be enabled with a flag (e.g. stack --nix build.

@martyall
Copy link
Collaborator

Hey @alexfmpe, sorry I'm just getting around to trying this. I was responsible for organizing two workshops at Devcon this year in Osaka, so was a bit busy in addition to working on some of the SDK stuff. I'm getting some failures, maybe you know why:


> stack --nix build
...
<bunch of build lines not indicating failure>
...
Hunk #1 succeeded at 183 (offset 13 lines).
Hunk #2 succeeded at 202 (offset 13 lines).
Hunk #3 succeeded at 231 (offset 13 lines).
patching file Lib/distutils/unixccompiler.py
Hunk #3 FAILED at 183.
1 out of 3 hunks FAILED -- saving rejects to file Lib/distutils/unixccompiler.py.rej
patching file Makefile.pre.in
Hunk #1 succeeded at 615 (offset 31 lines).
builder for '/nix/store/q325bf3n7y33nszmsn9pgcnxbp3dpava-python3-3.7.3.drv' failed with exit code 1
cannot build derivation '/nix/store/26rq8gd6dh6vzn9rzz56ljqdr1sq90wi-ghc-8.6.4.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/718vngg408fw0sksczf35hzyjlam73py-hlint-2.1.15.drv': 1 dependencies couldn't be built
error: build of '/nix/store/5v0h857h08nny0pgg6d02zp9pdlgb0d5-stylish-haskell-0.9.2.1.drv', '/nix/store/718vngg408fw0sksczf35hzyjlam73py-hlint-2.1.15.drv', '/nix/store/klzr8x8i7rys4x45y50crdiw1j29iajf-stack-1.9.3.drv' failed

@alexfmpe
Copy link
Contributor Author

No problem. I'll take a look.

@alexfmpe
Copy link
Contributor Author

alexfmpe commented Oct 22, 2019

Was this on a mac? The command worked fine on my NixOS, but I reproduced that error on my Mac. I think we were running into NixOS/nixpkgs#65927. I bumped nixpkgs to include the PR addressing it and it builds on both systems for me now.

@alexfmpe
Copy link
Contributor Author

stack --nix test --skip hs-abci-example-e2e; stack --nix test hs-abci-example --test-arguments "-m handlers" also worked.
I think this is mergeable - should I add anything to travis.yml?

@kejace
Copy link
Member

kejace commented Oct 22, 2019

FWIW I tested both on Mac and Linux and am getting the same error(s):

    Configuring hs-abci-types-0.1.0.0...
    ==========
    Error: couldn't find the executable "protoc" in your $PATH.
        Follow the installation instructions at https://google.github.io/proto-lens/installing-protoc.html .
    ==========
    Missing executable "protoc"
    CallStack (from HasCallStack):

and on Mac I get the additional

    Configuring zlib-0.6.2...
    Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5: Missing dependency on a foreign
    library:
    * Missing (or bad) header file: zlib.h
    * Missing (or bad) C library: z

Thought these might provide good data points. I'm assuming you both have the required protoc in PATH already and might not see these?

@alexfmpe
Copy link
Contributor Author

alexfmpe commented Oct 22, 2019

I do not have protoc or zlib on the path.
Are you passing the --nix flag? I get a similar error if I don't.

$ stack test --skip hs-abci-example-e2e
lens-labels-0.3.0.1: configure
lens-labels-0.3.0.1: build
proto-lens-arbitrary-0.1.2.7: configure
proto-lens-arbitrary-0.1.2.7: build
lens-labels-0.3.0.1: copy/register
proto-lens-arbitrary-0.1.2.7: copy/register
hs-abci-types-0.1.0.0: configure (lib + test)
hs-abci-types-0.1.0.0: build (lib + test)
Log files have been written to: /Users/alexfmpe/repos/hs-abci/.stack-work/logs/
Progress 3/10

--  While building package hs-abci-types-0.1.0.0 using:
      /Users/alexfmpe/repos/hs-abci/hs-abci-types/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/setup --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 build lib:hs-abci-types test:hs-abci-types-test --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/alexfmpe/repos/hs-abci/.stack-work/logs/hs-abci-types-0.1.0.0.log

    Configuring hs-abci-types-0.1.0.0...
    ==========
    Error: couldn't find the executable "protoc" in your $PATH.
        Follow the installation instructions at https://google.github.io/proto-lens/installing-protoc.html .
    ==========
    Missing executable "protoc"
    CallStack (from HasCallStack):
      error, called at src/Data/ProtoLens/Setup.hs:416:13 in proto-lens-setup-0.4.0.2-GFDS8LI2fBR7oCLeuJa15V:Data.ProtoLens.Setup
$ stack --nix test --skip hs-abci-example-e2e
hs-abci-example-0.1.0.0: test (suite: hs-abci-example-test)
hs-abci-types-0.1.0.0: test (suite: hs-abci-types-test)
hs-abci-server-0.1.0.0: test (suite: hs-abci-server-test)
hs-abci-example-0.1.0.0: Test suite hs-abci-example-test passed
hs-abci-server-0.1.0.0: Test suite hs-abci-server-test passed
hs-abci-types-0.1.0.0: Test suite hs-abci-types-test passed
Completed 3 action(s).
Log files have been written to: /Users/alexfmpe/repos/hs-abci/.stack-work/logs/

@kejace
Copy link
Member

kejace commented Oct 22, 2019

web-scale ➜  hs-abci git:(f28509b) ✗ stack --nix test --skip hs-abci-example-e2e
hs-abci-types       > configure (lib + test)
hs-abci-types       > Configuring hs-abci-types-0.1.0.0...
zlib                > configure
hs-abci-types       > build (lib + test)
hs-abci-types       > ==========
hs-abci-types       > Error: couldn't find the executable "protoc" in your $PATH.
hs-abci-types       >     Follow the installation instructions at https://google.github.io/proto-lens/installing-protoc.html .
hs-abci-types       > ==========
hs-abci-types       > Missing executable "protoc"
hs-abci-types       > CallStack (from HasCallStack):
hs-abci-types       >   error, called at src/Data/ProtoLens/Setup.hs:416:13 in proto-lens-setup-0.4.0.2-7TSweLEnBUR8ZEfewWdmvP:Data.ProtoLens.Setup
zlib                > Configuring zlib-0.6.2...
zlib                > Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5: Missing dependency on a foreign
zlib                > library:
zlib                > * Missing (or bad) header file: zlib.h
zlib                > * Missing (or bad) C library: z
zlib                > This problem can usually be solved by installing the system package that
zlib                > provides this library (you may need the "-dev" version). If the library is
zlib                > already installed but in a non-standard location then you can use the flags
zlib                > --extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
zlib                > library file does exist, it may contain errors that are caught by the C
zlib                > compiler at the preprocessing stage. In this case you can re-run configure
zlib                > with the verbosity flag -v3 to see the error messages.
zlib                > If the header file does exist, it may contain errors that are caught by the C
zlib                > compiler at the preprocessing stage. In this case you can re-run configure
zlib                > with the verbosity flag -v3 to see the error messages.
zlib                >

If we change the .travis.yml to use the nix file on this branch I would be convinced that this is an issue with my local configuration (despite it happening on two different machines).

@alexfmpe
Copy link
Contributor Author

The one thing I can think of is that you might have built without the nix flag, and then stack didn't rebuild properly for whatever reason.
I think doing a clean or a fresh checkout would rule that out.

I can adapt the .travis.yml file - is adding the equivalent of make test-without-e2e sufficient?

@martyall
Copy link
Collaborator

yes that should work

@martyall martyall merged commit 4876fb0 into f-o-a-m:master Nov 7, 2019
@alexfmpe alexfmpe deleted the stack-nix branch April 26, 2024 11:11
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

Successfully merging this pull request may close these issues.

3 participants