Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions pkgs/by-name/pe/perfect_dark/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
lib,
stdenv,
fetchFromGitHub,
SDL2,
sdl2-compat,
cmake,
libGL,
pkg-config,
python3,
zlib,
unstableGitUpdater,
romID ? "ntsc-final",
}:
let
Expand All @@ -27,14 +28,20 @@ stdenv.mkDerivation (finalAttrs: {
owner = "fgsfdsfgs";
repo = "perfect_dark";
rev = "bb4fcffeb5dc382fce4c609897a2e82590d7d709";
hash = "sha256-XLmAjwEzz4fPpHuk3IBmhhDfiuudwMTnYgVe6Wcfdsg=";
hash = "sha256-naWE+oWgvrd4CSoBm6W4em60baTWn4uSnKbWh8WKPDM=";

postFetch = ''
pushd $out
rm tools/gzip
rm -r tools/mkrom
popd
'';
};

enableParallelBuilding = true;

# Fails to build if not set:
hardeningDisable = [ "format" ];
hardeningEnable = [ "pie" ];

cmakeFlags = [
(lib.cmakeFeature "ROMID" romID)
Expand All @@ -47,7 +54,7 @@ stdenv.mkDerivation (finalAttrs: {
];

buildInputs = [
SDL2
sdl2-compat
libGL
zlib
];
Expand All @@ -72,7 +79,7 @@ stdenv.mkDerivation (finalAttrs: {
'';

preConfigure = ''
patchShebangs --build .
patchShebangs --build tools/assetmgr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why specify this path? doesn't this makes the process less robust to future changes?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally should only patch files which need to be patched. I'd rather the build fail because of an unpatched file that we can review and add than have a new patched file execute without us knowing when updating.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I can drop this change if it's really not worth it, we can see what @SigmaSquadron says.

Copy link
Contributor

@PaulGrandperrin PaulGrandperrin Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this particular case, it's safe to assume that any script is either part of the build process (and will need the patching) or will not be used at runtime (because we install only one binary in /bin/).

In any case, it's not important.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @normalcea here. It's best if we have absolute control over which files in the source are executable.

'';

installPhase = ''
Expand All @@ -91,6 +98,10 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';

passthru = {
updateScript = unstableGitUpdater { hardcodeZeroVersion = true; };
};

meta = {
description = "Modern cross-platform port of Perfect Dark";
longDescription = ''
Expand All @@ -114,8 +125,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with lib.licenses; [
# perfect_dark, khrplatform.h, port/fast3d
mit
# Vendored source code and binaries of 'gzip'.
gpl3Plus
# Derivative work of "Perfect Dark" © 2000 Rare Ltd.
unfree
];
Expand Down
Loading