17 , withJACK ? stdenv.hostPlatform.isUnix
23 # Enable GL/GLES rendering
24 , withGL ? !stdenv.hostPlatform.isDarwin
25 # Use GLES instead of GL, some platforms have better support for one than the other
26 , preferGLES ? stdenv.hostPlatform.isAarch
29 stdenv.mkDerivation (finalAttrs: {
33 src = fetchFromGitHub {
36 rev = "v${finalAttrs.version}";
37 fetchSubmodules = true;
38 hash = "sha256-G5yjqsep+hDGXCqGNBKoMvV7JOD7ZZTxTPBl9VmG8RM=";
41 postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
42 # To offer scaling detection on X11, furnace checks if libX11.so is available via dlopen and uses some of its functions
43 # But it's being linked against a versioned libX11.so.VERSION via SDL, so the unversioned one is not on the rpath
44 substituteInPlace src/gui/scaling.cpp \
45 --replace-fail 'libX11.so' '${lib.getLib libX11}/lib/libX11.so'
51 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
64 ] ++ lib.optionals withJACK [
66 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
67 # portaudio pkg-config is pulling this in as a link dependency, not set in propagatedBuildInputs
69 ] ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
74 (lib.cmakeBool "BUILD_GUI" withGUI)
75 (lib.cmakeBool "SYSTEM_FFTW" true)
76 (lib.cmakeBool "SYSTEM_FMT" true)
77 (lib.cmakeBool "SYSTEM_LIBSNDFILE" true)
78 (lib.cmakeBool "SYSTEM_RTMIDI" true)
79 (lib.cmakeBool "SYSTEM_SDL2" true)
80 (lib.cmakeBool "SYSTEM_ZLIB" true)
81 (lib.cmakeBool "USE_FREETYPE" true)
82 (lib.cmakeBool "SYSTEM_FREETYPE" true)
83 (lib.cmakeBool "WITH_JACK" withJACK)
84 (lib.cmakeBool "WITH_PORTAUDIO" true)
85 (lib.cmakeBool "SYSTEM_PORTAUDIO" true)
86 (lib.cmakeBool "WITH_RENDER_SDL" true)
87 (lib.cmakeBool "WITH_RENDER_OPENGL" withGL)
88 (lib.cmakeBool "USE_GLES" (withGL && preferGLES))
89 (lib.cmakeBool "WITH_RENDER_METAL" false) # fails to build
90 (lib.cmakeBool "WITH_RENDER_OPENGL1" (withGL && !preferGLES))
91 (lib.cmakeBool "FORCE_APPLE_BIN" true)
94 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
95 # Normal CMake install phase on Darwin only installs the binary, the user is expected to use CPack to build a
96 # bundle. That adds alot of overhead for not much benefit (CPack is currently abit broken, and needs impure access
97 # to /usr/bin/hdiutil). So we'll manually assemble & install everything instead.
99 mkdir -p $out/{Applications/Furnace.app/Contents/{MacOS,Resources},share/{,doc,licenses}/furnace}
100 mv $out/{bin,Applications/Furnace.app/Contents/MacOS}/furnace
101 makeWrapper $out/{Applications/Furnace.app/Contents/MacOS,bin}/furnace
103 install -m644 {../res,$out/Applications/Furnace.app/Contents}/Info.plist
104 install -m644 ../res/icon.icns $out/Applications/Furnace.app/Contents/Resources/Furnace.icns
105 install -m644 {..,$out/share/licenses/furnace}/LICENSE
106 cp -r ../papers $out/share/doc/furnace/
107 cp -r ../demos $out/share/furnace/
111 updateScript = ./update.sh;
112 tests.version = testers.testVersion {
118 description = "Multi-system chiptune tracker compatible with DefleMask modules";
119 homepage = "https://github.com/tildearrow/furnace";
120 changelog = "https://github.com/tildearrow/furnace/releases/tag/v${finalAttrs.version}";
121 license = with lib.licenses; [ gpl2Plus ];
122 maintainers = with lib.maintainers; [ OPNA2608 ];
123 platforms = lib.platforms.all;
124 mainProgram = "furnace";