btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / ru / rutabaga_gfx / package.nix
blob9b8f5bec42f378b88bf1cef26b63b4b21f446520
1 { lib
2 , stdenv
3 , fetchgit
4 , fetchpatch
5 , cargo
6 , pkg-config
7 , rustPlatform
8 , aemu
9 , gfxstream
10 , libdrm
11 , libiconv
14 stdenv.mkDerivation (finalAttrs: {
15   pname = "rutabaga_gfx";
16   version = "0.1.2";
18   src = fetchgit {
19     url = "https://chromium.googlesource.com/crosvm/crosvm";
20     rev = "v${finalAttrs.version}-rutabaga-release";
21     fetchSubmodules = true;
22     hash = "sha256-0RJDKzeU7U6hc6CLKks8QcRs3fxN+/LYUbB0t6W790M=";
23   };
25   patches = [
26     # Make gfxstream optional
27     # https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4860836
28     (fetchpatch {
29       url = "https://chromium.googlesource.com/crosvm/crosvm/+/c3ad0e43eb12cbf737a6049e0134d483e337363f%5E%21/?format=TEXT";
30       decode = "base64 -d";
31       hash = "sha256-Ji1bK7jnRlg0OpDfCLcTHfPSiz3zYcdgsWL4n3EoIYI=";
32     })
33     # Fix error in Makefile where it uses eight spaces instead of a tab
34     # https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4863380
35     (fetchpatch {
36       url = "https://chromium.googlesource.com/crosvm/crosvm/+/fc415bccc43d36f63a2fd4c28878591bb1053450%5E%21/?format=TEXT";
37       decode = "base64 -d";
38       hash = "sha256-SLzlZ4o1+R2bGTPvA0a5emq97hOIIIHrubFhcQjqYwg=";
39     })
40     # Install the dylib on Darwin.
41     ./darwin-install.patch
42   ];
44   nativeBuildInputs = [ cargo pkg-config rustPlatform.cargoSetupHook ];
45   buildInputs = [ libiconv ] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform gfxstream) ([
46     aemu
47     gfxstream
48   ] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform libdrm) [
49     libdrm
50   ]);
52   cargoDeps = rustPlatform.fetchCargoTarball {
53     inherit (finalAttrs) src;
54     hash = "sha256-wuF3Isrp+u5J8jPQoPsIOWYGNKLSNa2pLfvladAWkLs=";
55   };
57   CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec;
58   "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" =
59     "${stdenv.cc.targetPrefix}cc";
61   postConfigure = ''
62     cd rutabaga_gfx/ffi
63     substituteInPlace Makefile --replace-fail pkg-config "$PKG_CONFIG"
64   '';
66   # make install always rebuilds
67   dontBuild = true;
69   makeFlags = [
70     "prefix=$(out)"
71     "OUT=target/${stdenv.hostPlatform.rust.cargoShortTarget}/release"
72   ];
74   meta = with lib; {
75     homepage = "https://crosvm.dev/book/appendix/rutabaga_gfx.html";
76     description = "cross-platform abstraction for GPU and display virtualization";
77     license = licenses.bsd3;
78     maintainers = with maintainers; [ qyliss ];
79     platforms = platforms.darwin ++ platforms.linux;
80   };