anchor.diff:  { lib
  -, mkDerivation
  +, stdenv
   , fetchFromGitHub
   , cmake
   , jdk8
   , jdk
   , zlib
   , file
  -, makeWrapper
  +, wrapQtAppsHook
   , xorg
   , libpulseaudio
   , qtbase
  
positive.code: , glfw
  , openal
  , msaClientID ? ""
  }:
  
  mkDerivation rec {
    pname = "polymc";
    version = "1.3.1";
  
    src = fetchFromGitHub {
      owner = "PolyMC";
      repo = "PolyMC";
      rev = version;
      sha256 = "sha256-oTzhKGDi1Kr3JXY9dYQf1rVDPFr52tJ7L+rb5LCbtBE=";
      fetchSubmodules = true;
    };
  
    nativeBuildInputs = [ cmake file jdk makeWrapper ];
    buildInputs = [ qtbase zlib quazip ];
  
    postPatch = ''
      # hardcode jdk paths
      substituteInPlace launcher/java/JavaUtils.cpp \
        --replace 'scanJavaDir("/usr/lib/jvm")' 'javas.append("${jdk}/lib/openjdk/bin/java")' \
        --replace 'scanJavaDir("/usr/lib32/jvm")' 'javas.append("${jdk8}/lib/openjdk/bin/java")'
    '';
  
    cmakeFlags = [ "-DLauncher_PORTABLE=0" ] ++
                 lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ];
  
    dontWrapQtApps = true;
  
  
negative.code:     ];
    in ''
      # xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
      wrapQtApp $out/bin/polymc \
        --set GAME_LIBRARY_PATH /run/opengl-driver/lib:${libpath} \
        --prefix POLYMC_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks} \
        --prefix PATH : ${lib.makeBinPath [ xorg.xrandr ]}
    '';
  
  