blob: ce2518031b2e6e5dd209f92a3d2adac79ceade79 (
plain) (
blame)
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
|
{ 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;
};
})
|