1{
2 version,
3 sha256,
4 lib,
5 runCommand,
6 fetchurl,
7 makeWrapper,
8 jre,
9}:
10
11let
12 mcVersion = builtins.head (lib.splitString "_" version);
13in
14runCommand "optifine-${mcVersion}"
15 {
16 pname = "optifine";
17 inherit version;
18
19 src = fetchurl {
20 url = "https://optifine.net/download?f=OptiFine_${version}.jar";
21 inherit sha256;
22 name = "OptiFine_${version}.jar";
23 };
24
25 nativeBuildInputs = [
26 jre
27 makeWrapper
28 ];
29
30 passthru.updateScript = {
31 command = [ ./update.py ];
32 supportedFeatures = [ "commit" ];
33 };
34
35 meta = with lib; {
36 homepage = "https://optifine.net/";
37 description = "Minecraft ${mcVersion} optimization mod";
38 longDescription = ''
39 OptiFine is a Minecraft optimization mod.
40 It allows Minecraft to run faster and look better with full support for HD textures and many configuration options.
41 This is for version ${mcVersion} of Minecraft.
42 '';
43 sourceProvenance = with sourceTypes; [ binaryBytecode ];
44 license = licenses.unfree;
45 maintainers = [ ];
46 platforms = platforms.unix;
47 mainProgram = "optifine";
48 };
49 }
50 ''
51 mkdir -p $out/{bin,lib/optifine}
52 cp $src $out/lib/optifine/optifine.jar
53
54 makeWrapper ${jre}/bin/java $out/bin/optifine \
55 --add-flags "-jar $out/lib/optifine/optifine.jar"
56 ''