If you want to use nix-shell
:
$ nix-shell -p 'haskellPackages.ghcWithPackages (p: [ p.GLUT ])'
will provide you a shell with ghc
that knows GLUT
I tried with this code (from the wiki page you mentioned)
import Graphics.UI.GLUT main :: IO () main = do (_progName, _args) <- getArgsAndInitialize _window <- createWindow "Hello World" displayCallback $= display mainLoop display :: DisplayCallback display = do clear [ ColorBuffer ] flush
But a more preferable way is to create shell.nix
, so you do not need to remember it. To use shell.nix
, just call nix-shell
with no argument in the directory where it is, or nix-shell /path/to/shell.nix
anywhere.
shell.nix
, adopted from manual
{ nixpkgs ? import <nixpkgs> {} }: with nixpkgs; let ghc = haskellPackages.ghcWithPackages (ps: with ps; [ GLUT ]); in stdenv.mkDerivation { name = "my-haskell-env"; buildInputs = [ ghc ]; shellHook = "eval $(egrep ^export ${ghc}/bin/ghc)"; }
For a larger project, you can use cabal
or stack
, but I think it will be a different story.
source share