diff --git a/pkgs/by-name/op/opensupaplex/darwin.patch b/pkgs/by-name/op/opensupaplex/darwin.patch new file mode 100644 index 000000000000..7db9432f7302 --- /dev/null +++ b/pkgs/by-name/op/opensupaplex/darwin.patch @@ -0,0 +1,16 @@ +diff --git a/src/sdl_common/audio.c b/src/sdl_common/audio.c +index 797c678..ebb9eda 100644 +--- a/src/sdl_common/audio.c ++++ b/src/sdl_common/audio.c +@@ -25,11 +25,7 @@ + + #if HAVE_SDL2 + #include +-#if TARGET_OS_MAC +-#include +-#else + #include +-#endif + #elif HAVE_SDL + #include + #include diff --git a/pkgs/by-name/op/opensupaplex/package.nix b/pkgs/by-name/op/opensupaplex/package.nix index b1cbe51469f0..cb95343bec73 100644 --- a/pkgs/by-name/op/opensupaplex/package.nix +++ b/pkgs/by-name/op/opensupaplex/package.nix @@ -9,6 +9,7 @@ opensupaplex, SDL2, SDL2_mixer, + desktopToDarwinBundle, }: let @@ -18,21 +19,30 @@ let sha256 = "sha256-nKeSBUGjSulbEP7xxc6smsfCRjyc/xsLykH0o3Rq5wo="; }; in -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "opensupaplex"; version = "7.1.2"; src = fetchFromGitHub { owner = "sergiou87"; repo = "open-supaplex"; - rev = "v${version}"; - sha256 = "sha256-hP8dJlLXE5J/oxPhRkrrBl1Y5e9MYbJKi8OApFM3+GU="; + tag = "v${finalAttrs.version}"; + hash = "sha256-hP8dJlLXE5J/oxPhRkrrBl1Y5e9MYbJKi8OApFM3+GU="; }; + patches = [ + ./reproducible-build.patch + ./darwin.patch + ]; + nativeBuildInputs = [ SDL2 # For "sdl2-config" copyDesktopItems + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + desktopToDarwinBundle ]; + buildInputs = [ SDL2_mixer ]; enableParallelBuilding = true; @@ -66,30 +76,32 @@ stdenv.mkDerivation rec { passthru.tests.version = testers.testVersion { package = opensupaplex; command = "opensupaplex --help"; - version = "v${version}"; + version = "v${finalAttrs.version}"; }; desktopItems = [ (makeDesktopItem { name = "opensupaplex"; - exec = meta.mainProgram; + exec = finalAttrs.meta.mainProgram; icon = "open-supaplex"; desktopName = "OpenSupaplex"; - comment = meta.description; + comment = finalAttrs.meta.description; categories = [ - "Application" "Game" ]; }) ]; + # Strip only the main binary, not the data files which would corrupt them. + stripExclude = [ "lib/opensupaplex/*" ]; + meta = { description = "Decompilation of Supaplex in C and SDL"; homepage = "https://github.com/sergiou87/open-supaplex"; - changelog = "https://github.com/sergiou87/open-supaplex/blob/master/changelog/v${version}.txt"; + changelog = "https://github.com/sergiou87/open-supaplex/blob/master/changelog/v${finalAttrs.version}.txt"; license = lib.licenses.gpl3Only; maintainers = with lib.maintainers; [ matteopacini ]; - platforms = lib.platforms.linux; # Many more are supported upstream, but only linux is tested. + platforms = lib.platforms.linux ++ lib.platforms.darwin; mainProgram = "opensupaplex"; }; -} +}) diff --git a/pkgs/by-name/op/opensupaplex/reproducible-build.patch b/pkgs/by-name/op/opensupaplex/reproducible-build.patch new file mode 100644 index 000000000000..3c2a14917064 --- /dev/null +++ b/pkgs/by-name/op/opensupaplex/reproducible-build.patch @@ -0,0 +1,17 @@ +diff --git a/linux/Makefile b/linux/Makefile +index 6041a89..588341c 100644 +--- a/linux/Makefile ++++ b/linux/Makefile +@@ -5,6 +5,12 @@ LDFLAGS += -lSDL2_mixer -lvorbis -logg `sdl2-config --libs` -lm + + CFLAGS += `sdl2-config --cflags` -DHAVE_SDL2 + ++UNAME_S := $(shell uname -s) ++ifeq ($(UNAME_S),Darwin) ++# Darwin-specific reproducible build flags ++LDFLAGS += -Wl,-no_uuid ++endif ++ + opensupaplex: $(obj) + $(CC) -o $@ $^ $(LDFLAGS) +