collab/mame-tgm

packaging mame for playing tgm1/2

git clone https://git.julia.blue/collab/mame-tgm

Julia Ryanautomatically create config filefbcd7a9

main
1.7 KiB72 linesraw
1{ stdenvNoCC
2, lib
3, replaceVars
4, runtimeShell
5, fetchurl
6, imagemagick
7, moreutils
8, makeDesktopItem
9, copyDesktopItems
10, mame-tgm-unwrapped
11
12, gameName ? null
13, extraArgs ? []
14, desktopItemExtraAttrs ? {}
15, icon ? null
16}:
17
18stdenvNoCC.mkDerivation (finalAttrs: let
19  script = replaceVars ./mame-tgm-wrapper.bash {
20    inherit runtimeShell;
21    mameTgm = lib.getExe mame-tgm-unwrapped;
22    sponge = lib.getExe' moreutils "sponge";
23    extraArgs = extraArgs;
24  };
25
26  mainProgram = if gameName == null then "tgm-mame" else gameName;
27
28  desktopItem = makeDesktopItem ({
29    desktopName = "MAME for Tetris The Grandmaster";
30    name = "MAME TGM";
31    exec = mainProgram;
32    icon = mainProgram;
33    categories = [ "Game" ];
34    keywords = [ "tetris" "TGM" "emulator" "arika" "block" "stacking" ];
35  } // desktopItemExtraAttrs);
36in {
37  pname = "mame-wrapper-${mainProgram}";
38  inherit (mame-tgm-unwrapped) version;
39
40  nativeBuildInputs = [ copyDesktopItems imagemagick ];
41  desktopItems = [ desktopItem ];
42
43  dontUnpack = true;
44  buildPhase = ''
45    runHook preBuild
46
47    mkdir -p "$out/bin"
48    cp "${script}" "$out/bin/${mainProgram}"
49    chmod +x "$out/bin/${mainProgram}"
50
51    runHook postBuild
52  '';
53
54  icon = if icon != null then icon else (fetchurl {
55    url = "https://cdn2.steamgriddb.com/icon_thumb/f8548a8d98a27fe73f2558a90f989c5c.png";
56    hash = "sha256-b/8ZIvY5cPSgWKbPWDVVGz/oAqNzOwghHgqzXxn251A=";
57  });
58  installPhase = lib.optionalString (icon != null) ''
59    runHook preInstall
60
61    dir="$out/share/icons/hicolor/256x256/apps"
62    mkdir -p $dir
63    magick ${icon} -resize '256x256!' $dir/${mainProgram}.png    
64
65    runHook postInstall
66  '';
67
68  meta = {
69    inherit mainProgram;
70    inherit (mame-tgm-unwrapped) maintainers;
71  };
72})