about summary refs log tree commit diff
path: root/pkgs/development/compilers/minimacy/default.nix
blob: 557be6880e78ebf5475f7c06999c72df9450176f (plain) (blame)
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
{ lib
, stdenv
, alsa-lib
, fetchFromGitHub
, libGL
, libGLU
, libX11
, libXext
, makeBinaryWrapper
}:

stdenv.mkDerivation rec {
  pname = "minimacy";
  version = "0.6.4";

  src = fetchFromGitHub {
    owner = "ambermind";
    repo = pname;
    rev =  version;
    hash = "sha256-qIK7QnXZ9FmfarMZaHktZCHhvR8cctyKVpFS8PeOpLs=";
  };

  nativeBuildInputs = [ makeBinaryWrapper ];

  buildInputs = [ libGL libGLU ] ++ lib.optionals stdenv.isLinux [ alsa-lib libX11 libXext ];

  enableParallelBuilding = true;

  env.NIX_CFLAGS_COMPILE = "-Wno-unused-result";

  preBuild = ''
    pushd ${if stdenv.isDarwin then "macos/cmdline" else "unix"}
  '';

  # TODO: build graphic version for darwin
  buildFlags = (if stdenv.isDarwin then [ "nox" ] else [ "all" ]) ++ [ "CC=${stdenv.cc.targetPrefix}cc" ];

  postBuild = ''
    popd
  '';

  doCheck = true;

  checkPhase = ''
    runHook preCheck

    bin/${if stdenv.isDarwin then "minimacyMac" else "minimacy"} system/demo/demo.fun.mandelbrot.mcy

    runHook postCheck
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/lib/minimacy
    cp -r {README.md,LICENSE,system,rom,topLevel.mcy} $out/lib/minimacy
    install bin/minimacy* -Dt $out/bin

    runHook postInstall
  '';

  postFixup = ''
    for prog in $out/bin/minimacy*;
      do wrapProgram $prog \
        --set MINIMACY $out/lib/minimacy
      done
  '';

  meta = {
    description = "An open-source minimalist computing technology";
    longDescription = ''
      Minimacy is an open-source minimalist computation system based on the principle "Less is more".
      It is designed and programmed by Sylvain Huet.
    '';
    maintainers = with lib.maintainers; [ jboy ];
    homepage    = "https://minimacy.net";
    license     = lib.licenses.gpl2;
    platforms   = lib.platforms.linux ++ lib.platforms.darwin;
  };
}