summaryrefslogtreecommitdiff
path: root/package.nix
blob: 4d3a7fad93968107aca7b01701236b27bff97e9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
  haskellPackages,
  lib,
  stdenv,
  ...
}: let
  ghcExeOptions = lib.concatStringsSep " " ghcFlags;
  ghcFlags = [
    "-O"
    "-Wall"
    "-Widentities"
    "-Wincomplete-record-updates"
    "-Wincomplete-uni-patterns"
    # "-Wmissing-export-lists"
    "-Wmissing-home-modules"
    "-Wpartial-fields"
    "-Wredundant-constraints"
    "-threaded"
    "-rtsopts"
    "-with-rtsopts=-N"
    # src
    "-i./src"
    "-main-is Game"
  ];
  haddockOptions = lib.concatStringsSep " " haddockFlags;
  haddockFlags = [
    "--html"
    "--odir docs"
    "--optghc=-i./src"
    "src/Game/Main.hs"
  ];
  ghcPackages = p: [
    p.GLFW-b
    p.linear
    p.OpenGL
  ];
in
  stdenv.mkDerivation {
    pname = "haskengl";
    version = "0.1.0";
    src = ./.;
    nativeBuildInputs = [
      (haskellPackages.ghcWithPackages ghcPackages)
    ];
    buildInputs = [
    ];
    configurePhase = ''
    '';
    buildPhase = ''
      ghc ${ghcExeOptions} ./src/Game.hs -o ./Main
      haddock ${haddockOptions}
    '';
    installPhase = ''
      mkdir -p $out/bin
      cp ./Main $out/bin/hs-game
      cp ./docs $out/docs -r
    '';

    meta = {
      homepage = "https://mtgmonkey.net";
      license = lib.licenses.wtfpl;
      mainProgram = "hs-game";
      platforms = ["x86_64-linux"];
    };
  }