This repository has no description
2.0 kB
101 lines
1# Shared builder for Haunted PS1 demo disc games
2{
3 lib,
4 stdenv,
5 requireFile,
6 unzip,
7 makeWrapper,
8 umu-launcher,
9 makeDesktopItem,
10 copyDesktopItems,
11}:
12
13{
14 pname,
15 version ? "1.0",
16 zipName,
17 sha256,
18 exeName,
19 downloadUrl,
20 downloadName,
21 desktopName,
22 description,
23}:
24
25let
26 src = requireFile {
27 name = zipName;
28 inherit sha256;
29 message = ''
30 To use this package, you need to download ${desktopName}.
31
32 1. Go to ${downloadUrl}
33 2. Create a free itch.io account or log in
34 3. Click the "Download" button for "${downloadName}"
35 4. Once downloaded, add it to the Nix store:
36
37 nix-store --add-fixed sha256 ~/Downloads/${zipName}
38
39 Then try building again.
40 '';
41 };
42
43 desktopItem = makeDesktopItem {
44 name = pname;
45 inherit desktopName;
46 comment = description;
47 exec = pname;
48 icon = pname;
49 categories = [ "Game" ];
50 };
51
52in
53stdenv.mkDerivation {
54 inherit pname version src;
55
56 nativeBuildInputs = [
57 unzip
58 makeWrapper
59 copyDesktopItems
60 ];
61
62 desktopItems = [ desktopItem ];
63
64 dontBuild = true;
65
66 unpackPhase = ''
67 runHook preUnpack
68 unzip -q "$src"
69 runHook postUnpack
70 '';
71
72 installPhase = ''
73 runHook preInstall
74
75 # Install all game files
76 mkdir -p "$out/share/${pname}"
77 cp -r * "$out/share/${pname}/"
78
79 # Create wrapper script using umu-run (Proton launcher)
80 mkdir -p "$out/bin"
81 cat > "$out/bin/${pname}" <<WRAPPER
82 #!/bin/sh
83 export WINEPREFIX="\''${WINEPREFIX:-\$HOME/.local/share/${pname}/prefix}"
84 export GAMEID="${pname}"
85 export PROTONPATH="GE-Proton"
86 exec ${umu-launcher}/bin/umu-run "\$out/share/${pname}/${exeName}" "\$@"
87 WRAPPER
88 substituteInPlace "$out/bin/${pname}" --replace-fail '$out' "$out"
89 chmod +x "$out/bin/${pname}"
90
91 runHook postInstall
92 '';
93
94 meta = {
95 inherit description;
96 homepage = downloadUrl;
97 license = lib.licenses.unfree;
98 platforms = [ "x86_64-linux" ];
99 mainProgram = pname;
100 };
101}