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