summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/sw/switchres/package.nix
blob: b94b4c35375448d50c5c191983981544035f1962 (plain)
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
{
  stdenv,
  lib,
  pkg-config,
  fetchFromGitHub,
  libxrandr,
  libx11,
  xorgproto,
  libdrm,
  SDL2,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "switchres";
  version = "2.2.2";

  src = fetchFromGitHub {
    owner = "antonioginer";
    repo = "switchres";
    tag = "v${finalAttrs.version}";
    hash = "sha256-jHMZuROSmRhCKb0AV3t1WUJZMOnB4ahx+ZcrWRFmTrM=";
  };

  nativeBuildInputs = [
    pkg-config
  ];

  buildInputs = [
    libxrandr
    xorgproto
    libdrm
    SDL2
  ];

  patchPhase = ''
    runHook prePatch

    substituteInPlace ./custom_video_xrandr.cpp \
      --replace-fail libX11.so ${libx11}/lib/libX11.so \
      --replace-fail libXrandr.so ${libxrandr}/lib/libXrandr.so

    substituteInPlace ./custom_video_drmkms.cpp \
      --replace-fail libdrm.so ${libdrm}/lib/libdrm.so \

    runHook postPatch
  '';

  env = {
    PREFIX = "$(out)";
  };

  preInstall = ''
    install -Dm755 switchres $out/bin/switchres
  '';

  meta = {
    description = "Modeline generation engine for emulation";
    homepage = "https://github.com/antonioginer/switchres";
    changelog = "https://github.com/antonioginer/switchres/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.gpl2Only;
    mainProgram = "switchres";
    maintainers = with lib.maintainers; [ bot-wxt1221 ];
    platforms = lib.platforms.linux;
  };
})