1{
2 lib,
3 stdenv,
4 fetchurl,
5 wrapGAppsHook3,
6 wxGTK,
7 python3,
8 zlib,
9 libGLU,
10 libGL,
11 libX11,
12 SDL2,
13}:
14stdenv.mkDerivation (finalAttrs: {
15 pname = "golly";
16 version = "4.3";
17
18 src = fetchurl {
19 hash = "sha256-UdJHgGPn7FDN4rYTgfPBAoYE5FGC43TP8OFBmYIqCB0=";
20 url = "mirror://sourceforge/project/golly/golly/golly-${finalAttrs.version}/golly-${finalAttrs.version}-src.tar.gz";
21 };
22
23 buildInputs = [
24 wxGTK
25 python3
26 zlib
27 libGLU
28 libGL
29 libX11
30 SDL2
31 ];
32
33 nativeBuildInputs = [
34 (python3.withPackages (ps: [ ps.setuptools ]))
35 wrapGAppsHook3
36 ];
37
38 # fails nondeterministically on darwin
39 enableParallelBuilding = false;
40
41 setSourceRoot = ''
42 sourceRoot=$(echo */gui-wx)
43 '';
44
45 postPatch = ''
46 substituteInPlace wxprefs.cpp \
47 --replace-fail 'PYTHON_SHLIB' '${python3}/lib/libpython3.so'
48 ''
49 + lib.optionalString stdenv.hostPlatform.isDarwin ''
50 substituteInPlace makefile-gtk \
51 --replace-fail '-Wl,--as-needed' "" \
52 --replace-fail '-lGL ' "" \
53 --replace-fail '-lGLU' ""
54 '';
55
56 makeFlags = [
57 "-f"
58 "makefile-gtk"
59 "ENABLE_SOUND=1"
60 "GOLLYDIR=${placeholder "out"}/share/golly"
61 "CC=${stdenv.cc.targetPrefix}cc"
62 "CXX=${stdenv.cc.targetPrefix}c++"
63 "CXXC=${stdenv.cc.targetPrefix}c++"
64 "LD=${stdenv.cc.targetPrefix}c++"
65 "WX_CONFIG=${lib.getExe' (lib.getDev wxGTK) "wx-config"}"
66 ];
67
68 installPhase = ''
69 runHook preInstall
70
71 mkdir -p "$out/bin"
72 cp ../golly ../bgolly "$out/bin"
73
74 mkdir -p "$out/share/doc/golly/"
75 cp ../docs/* "$out/share/doc/golly/"
76
77 mkdir -p "$out/share/golly"
78 cp -r ../{Help,Patterns,Scripts,Rules} "$out/share/golly"
79
80 runHook postInstall
81 '';
82
83 meta = {
84 description = "Cellular automata simulation program";
85 license = lib.licenses.gpl2Plus;
86 maintainers = with lib.maintainers; [
87 raskin
88 siraben
89 ];
90 platforms = lib.platforms.unix;
91 homepage = "https://golly.sourceforge.io/";
92 downloadPage = "https://sourceforge.net/projects/golly/files/golly";
93 };
94})