1{ lib
2, stdenv
3, alsa-lib
4, fetchFromGitHub
5, libGL
6, libGLU
7, libX11
8, libXext
9, makeBinaryWrapper
10}:
11
12stdenv.mkDerivation rec {
13 pname = "minimacy";
14 version = "1.0.0";
15
16 src = fetchFromGitHub {
17 owner = "ambermind";
18 repo = pname;
19 rev = version;
20 hash = "sha256-cpxKZ77Noe/2et3ROAQwG2LJxrlsEfi+bmUj+QaPkk0=";
21 };
22
23 nativeBuildInputs = [ makeBinaryWrapper ];
24
25 buildInputs = [ libGL libGLU ] ++ lib.optionals stdenv.isLinux [ alsa-lib libX11 libXext ];
26
27 enableParallelBuilding = true;
28
29 env.NIX_CFLAGS_COMPILE = "-Wno-unused-result";
30
31 preBuild = ''
32 pushd ${if stdenv.isDarwin then "macos/cmdline" else "unix"}
33 '';
34
35 # TODO: build graphic version for darwin
36 buildFlags = (if stdenv.isDarwin then [ "nox" ] else [ "all" ]) ++ [ "CC=${stdenv.cc.targetPrefix}cc" ];
37
38 postBuild = ''
39 popd
40 '';
41
42 doCheck = true;
43
44 checkPhase = ''
45 runHook preCheck
46
47 bin/${if stdenv.isDarwin then "minimacyMac" else "minimacy"} system/demo/demo.fun.mandelbrot.mcy
48
49 runHook postCheck
50 '';
51
52 installPhase = ''
53 runHook preInstall
54
55 mkdir -p $out/lib/minimacy
56 cp -r {README.md,LICENSE,system,rom,topLevel.mcy} $out/lib/minimacy
57 install bin/minimacy* -Dt $out/bin
58
59 runHook postInstall
60 '';
61
62 postFixup = ''
63 for prog in $out/bin/minimacy*;
64 do wrapProgram $prog \
65 --set MINIMACY $out/lib/minimacy
66 done
67 '';
68
69 meta = {
70 description = "An open-source minimalist computing technology";
71 longDescription = ''
72 Minimacy is an open-source minimalist computation system based on the principle "Less is more".
73 It is designed and programmed by Sylvain Huet.
74 '';
75 maintainers = with lib.maintainers; [ jboy ];
76 homepage = "https://minimacy.net";
77 license = lib.licenses.gpl2;
78 platforms = lib.platforms.linux ++ lib.platforms.darwin;
79 };
80}