···
11
+
romID ? "ntsc-final",
20
+
assert lib.assertOneOf "romID" romID roms;
22
+
stdenv.mkDerivation (finalAttrs: {
23
+
pname = "perfect_dark";
24
+
version = "0-unstable-2025-08-25";
26
+
src = fetchFromGitHub {
27
+
owner = "fgsfdsfgs";
28
+
repo = "perfect_dark";
29
+
rev = "bb4fcffeb5dc382fce4c609897a2e82590d7d709";
30
+
hash = "sha256-XLmAjwEzz4fPpHuk3IBmhhDfiuudwMTnYgVe6Wcfdsg=";
33
+
enableParallelBuilding = true;
35
+
# Fails to build if not set:
36
+
hardeningDisable = [ "format" ];
37
+
hardeningEnable = [ "pie" ];
40
+
(lib.cmakeFeature "ROMID" romID)
43
+
nativeBuildInputs = [
56
+
# The project uses Git to retrieve version informations but our
57
+
# fetcher deletes the .git directory, so we replace the commands
58
+
# with the correct data directly.
60
+
substituteInPlace CMakeLists.txt \
61
+
--replace-fail "git rev-parse --short HEAD" \
62
+
"echo ${builtins.substring 0 9 finalAttrs.src.rev}" \
63
+
--replace-fail "git rev-parse --abbrev-ref HEAD" \
66
+
# Point toward the compiled binary and not the shell wrapper since
67
+
# the rom auto-detection logic is not needed in this build.
69
+
substituteInPlace dist/linux/io.github.fgsfdsfgs.perfect_dark.desktop \
70
+
--replace-fail "Exec=io.github.fgsfdsfgs.perfect_dark.sh" \
71
+
"Exec=io.github.fgsfdsfgs.perfect_dark"
75
+
patchShebangs --build .
82
+
install -Dm755 build/pd.* $out/bin/io.github.fgsfdsfgs.perfect_dark
83
+
install -Dm644 dist/linux/io.github.fgsfdsfgs.perfect_dark.desktop \
84
+
-t $out/share/applications
85
+
install -Dm644 dist/linux/io.github.fgsfdsfgs.perfect_dark.png \
86
+
-t $out/share/icons/hicolor/256x256/apps
87
+
install -Dm644 dist/linux/io.github.fgsfdsfgs.perfect_dark.metainfo.xml \
88
+
-t $out/share/metainfo
95
+
description = "Modern cross-platform port of Perfect Dark";
96
+
longDescription = ''
97
+
This is a port of Ryan Dywer's decompilation of classic N64
98
+
shooter Perfect Dark to modern systems.
100
+
You will need to provide a copy of the ROM at
101
+
`$HOME/.local/share/perfectdark/data/pd.${romID}.z64` to launch
104
+
Though `ntsc-final` is the recommended default, you can change
105
+
the ROM variant of this game with an expression like this:
108
+
perfect_dark.override { romID = "jpn-final"; }
111
+
Supported romIDs are `${lib.generators.toPretty { } roms}`.
113
+
homepage = "https://github.com/fgsfdsfgs/perfect_dark/";
114
+
license = with lib.licenses; [
115
+
# perfect_dark, khrplatform.h, port/fast3d
117
+
# Vendored source code and binaries of 'gzip'.
119
+
# Derivative work of "Perfect Dark" © 2000 Rare Ltd.
122
+
maintainers = with lib.maintainers; [
127
+
mainProgram = "io.github.fgsfdsfgs.perfect_dark";
128
+
platforms = lib.platforms.linux;