summaryrefslogtreecommitdiff
path: root/pkgs/development/compilers/microhs/common.nix
blob: 36d65abb2b69473ad4a318d69f336dd2d03b99a7 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{
  version,
  mcabalVersion ? "0.5.3.0-31f1b5dec81561a1b1d36b8e3065ce091dce2ec6",
  rev ? "refs/tags/v${version}",
  hash,
}:

{
  lib,
  buildPackages,
  pkgsBuildBuild,
  callPackage,
  fetchFromGitHub,
  fetchpatch,
  microhs-boot,
  stdenv,
  versionCheckHook,
  writeShellScript,
}:

let
  args = finalAttrs: {
    inherit version;

    src = fetchFromGitHub {
      owner = "augustss";
      repo = "MicroHs";
      fetchSubmodules = true;
      inherit rev hash;
    };

    patches = [
      patches/hugs.patch
      patches/hugs-viewpatterns.patch
    ]
    ++ lib.optional stdenv.hostPlatform.isGnu patches/link-math.patch;

    # The source contains pre-compiled files
    # We delete them to be certain we are building from source
    postPatch = ''
      rm -r generated
    '';

    doInstallCheck = true;

    nativeInstallCheckInputs = [
      versionCheckHook
    ];

    meta = {
      description = "Small compiler for Haskell";
      longDescription = ''
        A compiler for an extended subset of Haskell 2010.
        The compiler translates to combinators and can compile itself.
      '';
      homepage = "https://github.com/augustss/MicroHs";
      license = lib.licensesSpdx."Apache-2.0";
      mainProgram = "mhs";
      maintainers = with lib.maintainers; [
        AlexandreTunstall
        steeleduncan
      ];
      platforms = lib.platforms.all;
    };
  };

  microhs-stage1-build = pkgsBuildBuild.callPackage ./stage1.nix {
    inherit args microhs-boot;
  };

  microhs-stage1 = buildPackages.callPackage ./stage1.nix {
    inherit args microhs-boot;
  };

  microhs-stage2 = callPackage ./stage2.nix {
    inherit
      args
      microcabal-stage1
      microhs-stage1
      cpphs
      ;
  };

  microcabal-stage1 = buildPackages.callPackage ../../tools/haskell/microcabal/${mcabalVersion}.nix {
    microhs = microhs-stage1-build;
  };

  cpphs = buildPackages.callPackage ./cpphs.nix {
    inherit args;
    microhs = microhs-stage2;
  };

in
microhs-stage2