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

add nix dependencies to stack.yaml #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chris-martin
Copy link

I needed this to compile on NixOS.

@deech
Copy link
Owner

deech commented Jan 15, 2018

Nice, thanks! Does it still work if you enable the OpenGL flag?

@chris-martin
Copy link
Author

Nope!

Preprocessing library fltkhs-0.5.4.3...
In file included from ./c-src/Fl_C.h:5:0,
                 from .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Graphics/UI/FLTK/LowLevel/Gl.
chs.h:2:
/home/chris/haskell/fltkhs/c-src/Fl_Types.h:192:23: fatal error: GL/gl.h: No such file or directory
 #    include <GL/gl.h>
                       ^
compilation terminated.
c2hs: Error during preprocessing custom header file

--  While building custom Setup.hs for package fltkhs-0.5.4.3 using:
      /home/chris/haskell/fltkhs/.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/setup/setup --builddir=.
stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0 build lib:fltkhs exe:fltkhs-buttons exe:fltkhs-fluidtohs -
-ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

OpenGL is a problematic thing, I think. To my understanding (and I may be totally wrong there) you need to use the package that's specific to your GPU, so I don't know how this should be handled.

And if I add mesa and mesa_glu to the Nix package list, then I get this result:

Preprocessing library fltkhs-0.5.4.3...

<no location info>: error:
    module ‘Graphics.UI.FLTK.LowLevel.Gl’ is a package module

--  While building custom Setup.hs for package fltkhs-0.5.4.3 using:
      /home/chris/haskell/fltkhs/.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/setup/setup --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0 build lib:fltkhs exe:fltkhs-buttons exe:fltkhs-fluidtohs --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

@deech
Copy link
Owner

deech commented Jan 15, 2018

Cool! That last error is possibly a good sign. Try removing the local .stack-work directory, doing a stack clean and then stack build. I would also check that the fltk package from Nix is compiled with --enable-gl.

If that doesn't work try starting over but removing the fltk Nix dependency and doing stack build --flag fltkhs:bundled --flag fltkhs:opengl. This builds and links the bundled FLTK .

@sboosali
Copy link
Contributor

sboosali commented Jan 15, 2018 via email

@chris-martin
Copy link
Author

I had to get more aggressive than .stack-work and stack clean by running git clean -dxf, but you're right, it does now seem to build with the opengl flag.

Copy link
Contributor

@sboosali sboosali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since as far as I know stack doesn't have conditionals, I'd have two stack files: this, called stack-opengl.yaml, and a stack.yaml with only the default flags' deps:

nix:
  packages:
 - autoconf
 - c2hs  # still needs this, right?
 - fltk
 - libjpeg

@sboosali
Copy link
Contributor

(by "this" I mean the file in the PR)

also, is mesa_glu necessary? cabal2nix seems to choose only freeglut from the GLU dep, and it builds.

@chris-martin
Copy link
Author

(I have no idea, I'm at an "adding stuff until it seems to work" knowledge level here)

@sboosali
Copy link
Contributor

(same lol)

also, we want the flag:

flags:
  fltkhs:
    opengl: true

but idk if stack flags work with the local/current project (they should).

@sboosali
Copy link
Contributor

sboosali commented Jan 17, 2018

i.e. can you test this?

# stack-opengl.yaml

resolver: lts-8.13

packages:
- '.'

flags:
  fltkhs:
    opengl: true

nix:
  packages:
    # setup
    - autoconf
    - c2hs 
    # build
    - fltk
    - libjpeg
    # opengl
    - mesa
    - freeglut

@chris-martin
Copy link
Author

error: undefined variable ‘c2hs’ at (string):1:52

@sboosali
Copy link
Contributor

oh, should be qualified:

haskellPackages.c2hs

@chris-martin
Copy link
Author

Yep, seems to work.

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