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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
{ lib
, fetchFromGitHub
, buildGoModule
, alsa-lib
, libGL
, libX11
, libXcursor
, libXext
, libXi
, libXinerama
, libXrandr
, libXxf86vm
, go-licenses
, pkg-config
, zip
, advancecomp
, makeWrapper
, nixosTests
}:
buildGoModule rec {
pname = "aaaaxy";
version = "1.5.54";
src = fetchFromGitHub {
owner = "divVerent";
repo = pname;
rev = "v${version}";
hash = "sha256-FBla+KvUoUdCG0nM4falMJBq8NI75zqo/YSZy0bPFrE=";
fetchSubmodules = true;
};
vendorHash = "sha256-rE1YXDpiGnAUdmAaOHehyM38SPBqNvSRHhtXIUwRYVs=";
buildInputs = [
alsa-lib
libGL
libX11 libXcursor libXext libXi libXinerama libXrandr
libXxf86vm
];
nativeBuildInputs = [
go-licenses
pkg-config
zip
advancecomp
makeWrapper
];
outputs = [ "out" "testing_infra" ];
postPatch = ''
# Without patching, "go run" fails with the error message:
# package github.com/google/go-licenses: no Go files in /build/source/vendor/github.com/google/go-licenses
substituteInPlace scripts/build-licenses.sh --replace \
'$GO run ''${GO_FLAGS} github.com/google/go-licenses' 'go-licenses'
patchShebangs scripts/
substituteInPlace scripts/regression-test-demo.sh \
--replace 'sh scripts/run-timedemo.sh' "$testing_infra/scripts/run-timedemo.sh"
substituteInPlace Makefile --replace \
'CPPFLAGS ?= -DNDEBUG' \
'CPPFLAGS ?= -DNDEBUG -D_GLFW_GLX_LIBRARY=\"${lib.getLib libGL}/lib/libGL.so\" -D_GLFW_EGL_LIBRARY=\"${lib.getLib libGL}/lib/libEGL.so\"'
'';
overrideModAttrs = (_: {
# We can't patch in the path to libGL directly because
# this is a fixed output derivation and when the path to libGL
# changes, the hash would change.
# To work around this, use environment variables.
postBuild = ''
substituteInPlace 'vendor/github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl/gl/procaddr_others.go' \
--replace \
'{"libGL.so", "libGL.so.2", "libGL.so.1", "libGL.so.0"}' \
'{os.Getenv("EBITENGINE_LIBGL")}' \
--replace \
'{"libGLESv2.so", "libGLESv2.so.2", "libGLESv2.so.1", "libGLESv2.so.0"}' \
'{os.Getenv("EBITENGINE_LIBGLESv2")}'
'';
});
makeFlags = [
"BUILDTYPE=release"
];
buildPhase = ''
runHook preBuild
AAAAXY_BUILD_USE_VERSION_FILE=true make $makeFlags
runHook postBuild
'';
postInstall = ''
install -Dm755 'aaaaxy' -t "$out/bin/"
install -Dm444 'aaaaxy.svg' -t "$out/share/icons/hicolor/scalable/apps/"
install -Dm644 'aaaaxy.png' -t "$out/share/icons/hicolor/128x128/apps/"
install -Dm644 'aaaaxy.desktop' -t "$out/share/applications/"
install -Dm644 'io.github.divverent.aaaaxy.metainfo.xml' -t "$out/share/metainfo/"
wrapProgram $out/bin/aaaaxy \
--set EBITENGINE_LIBGL '${lib.getLib libGL}/lib/libGL.so' \
--set EBITENGINE_LIBGLESv2 '${lib.getLib libGL}/lib/libGLESv2.so'
install -Dm755 'scripts/run-timedemo.sh' -t "$testing_infra/scripts/"
install -Dm755 'scripts/regression-test-demo.sh' -t "$testing_infra/scripts/"
install -Dm644 'assets/demos/benchmark.dem' -t "$testing_infra/assets/demos/"
'';
passthru.tests = {
aaaaxy = nixosTests.aaaaxy;
};
strictDeps = true;
meta = with lib; {
description = "A nonlinear 2D puzzle platformer taking place in impossible spaces";
mainProgram = "aaaaxy";
homepage = "https://divverent.github.io/aaaaxy/";
license = licenses.asl20;
maintainers = with maintainers; [ Luflosi ];
platforms = platforms.linux;
};
}
|