fltkhs icon indicating copy to clipboard operation
fltkhs copied to clipboard

add nix dependencies to stack.yaml

Open chris-martin opened this issue 8 years ago • 12 comments

I needed this to compile on NixOS.

chris-martin avatar Jan 15 '18 06:01 chris-martin

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

deech avatar Jan 15 '18 11:01 deech

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

chris-martin avatar Jan 15 '18 18:01 chris-martin

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 .

deech avatar Jan 15 '18 19:01 deech

fwiw, the nix build file for fltk says it needs opengl, which can't be right

https://github.com/NixOS/nixpkgs/blob/360089b3521af0c69a5167870c80851dedf19d76/pkgs/development/libraries/fltk/default.nix#L46

On Jan 15, 2018 11:03 AM, "deech" [email protected] wrote:

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 .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/deech/fltkhs/pull/69#issuecomment-357764807, or mute the thread https://github.com/notifications/unsubscribe-auth/ACNoMX_mBJLFwdXxPxUeRkPlVP4whDl2ks5tK6DhgaJpZM4Rd9Rp .

sboosali avatar Jan 15 '18 19:01 sboosali

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.

chris-martin avatar Jan 17 '18 18:01 chris-martin

(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.

sboosali avatar Jan 17 '18 19:01 sboosali

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

chris-martin avatar Jan 17 '18 19:01 chris-martin

(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 avatar Jan 17 '18 19:01 sboosali

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

sboosali avatar Jan 17 '18 19:01 sboosali

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

chris-martin avatar Jan 17 '18 20:01 chris-martin

oh, should be qualified:

haskellPackages.c2hs

sboosali avatar Jan 17 '18 20:01 sboosali

Yep, seems to work.

chris-martin avatar Jan 17 '18 20:01 chris-martin