about summary refs log tree commit diff
path: root/pkgs/applications/emulators
diff options
context:
space:
mode:
authorFrancesco Gazzetta <fgaz@fgaz.me>2023-05-30 08:53:33 +0200
committerWeijia Wang <9713184+wegank@users.noreply.github.com>2023-08-02 19:37:21 +0200
commite82756d4f50273d92433e1d57e85738029042209 (patch)
treefc8bd484a583c19b07a4f235cef81b50fc42ac26 /pkgs/applications/emulators
parenta96075f5eebb8a5b8be6e0ad5de4b5fc13b9ed65 (diff)
tamatool: init at 0.1
Diffstat (limited to 'pkgs/applications/emulators')
-rw-r--r--pkgs/applications/emulators/tamatool/default.nix78
1 files changed, 78 insertions, 0 deletions
diff --git a/pkgs/applications/emulators/tamatool/default.nix b/pkgs/applications/emulators/tamatool/default.nix
new file mode 100644
index 0000000000000..ce2518031b2e6
--- /dev/null
+++ b/pkgs/applications/emulators/tamatool/default.nix
@@ -0,0 +1,78 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, zip
+, copyDesktopItems
+, libpng
+, SDL2
+, SDL2_image
+, darwin
+
+# Optionally bundle a ROM file
+, rom ? null
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "tamatool";
+  version = "0.1";
+
+  src = fetchFromGitHub {
+    owner = "jcrona";
+    repo = "tamatool";
+    rev = "v${finalAttrs.version}";
+    hash = "sha256-VDmpIBuMWg3TwfCf9J6/bi/DaWip6ESAQWvGh2SH+A8=";
+    fetchSubmodules = true;
+  };
+
+  # * Point to the installed rom and res directory
+  # * Tell the user to use --rom instead of telling them to place the rom in the
+  #   program directory (it's immutable!)
+  postPatch = ''
+    substituteInPlace src/tamatool.c \
+      --replace '#define RES_PATH'          "#define RES_PATH         \"$out/share/tamatool/res\"          //" \
+      --replace '#define ROM_PATH'          "#define ROM_PATH         \"$out/share/tamatool/rom.bin\"      //" \
+      --replace '#define ROM_NOT_FOUND_MSG' '#define ROM_NOT_FOUND_MSG "You need to use the --rom option!" //'
+  '';
+
+  nativeBuildInputs = [
+    zip
+    copyDesktopItems
+  ];
+
+  buildInputs = [
+    libpng
+    SDL2
+    SDL2_image
+  ] ++ lib.optionals stdenv.isDarwin [
+    darwin.apple_sdk.frameworks.CoreFoundation
+  ];
+
+  makeFlags = [
+    "-Clinux"
+    "VERSION=${finalAttrs.version}"
+    "CFLAGS+=-I${SDL2.dev}/include/SDL2"
+    "CFLAGS+=-I${SDL2_image}/include/SDL2"
+    "DIST_PATH=$(out)"
+    "CC=${stdenv.cc.targetPrefix}cc"
+  ];
+
+  desktopItems = [ "linux/tamatool.desktop" ];
+
+  installPhase = ''
+    runHook preInstall
+    install -Dm755 linux/tamatool $out/bin/tamatool
+    mkdir -p $out/share/tamatool
+    cp -r res $out/share/tamatool/res
+    install -Dm644 linux/tamatool.png $out/share/icons/hicolor/128x126/apps/tamatool.png
+    ${lib.optionalString (rom != null) "install -Dm677 ${rom} $out/share/tamatool/rom.bin"}
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "A cross-platform Tamagotchi P1 explorer";
+    homepage = "https://github.com/jcrona/tamatool";
+    license = licenses.gpl2Only;
+    maintainers = with maintainers; [ fgaz ];
+    platforms = platforms.all;
+  };
+})