about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/virtualization/rvvm/default.nix
blob: 718446d1ce1f6705aa141193986e4071cf2b03f1 (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
{ lib
, stdenv
, fetchFromGitHub

, SDL2

, libX11
, libXext

, guiBackend ? "sdl"

, enableSDL ? guiBackend == "sdl"
, enableX11 ? guiBackend == "x11"
}:

assert lib.assertMsg (builtins.elem guiBackend ["sdl" "x11" "none"]) "Unsupported GUI backend";
assert lib.assertMsg (!(enableSDL && enableX11)) "RVVM can have only one GUI backend at a time";
assert lib.assertMsg (stdenv.isDarwin -> !enableX11) "macOS supports only SDL GUI backend";

stdenv.mkDerivation rec {
  pname = "rvvm";
  version = "0.6";

  src = fetchFromGitHub {
    owner = "LekKit";
    repo = "RVVM";
    rev = "v${version}";
    sha256 = "sha256-5nSlKyWDAx0EeKFzzwP5+99XuJz9BHXEF1WNkRMLa9U=";
  };

  buildInputs = []
    ++ lib.optionals enableSDL [ SDL2 ]
    ++ lib.optionals enableX11 [ libX11 libXext ];

  enableParallelBuilding = true;

  buildFlags = [ "all" "lib" ];

  makeFlags = [ "PREFIX=$(out)" ]
    ++ lib.optional enableSDL "USE_SDL=2" # Use SDL2 instead of SDL1
    ++ lib.optional (!enableSDL && !enableX11) "USE_FB=0"

    # work around https://github.com/NixOS/nixpkgs/issues/19098
    ++ lib.optional (stdenv.cc.isClang && stdenv.isDarwin) "CFLAGS=-fno-lto";

  meta = with lib; {
    homepage = "https://github.com/LekKit/RVVM";
    description = "The RISC-V Virtual Machine";
    license = with licenses; [ gpl3 /* or */ mpl20 ];
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ kamillaova ];
    mainProgram = "rvvm";
  };
}