Skip to content

perfect_dark: init at 0-unstable-2025-08-25#306767

Merged
SigmaSquadron merged 2 commits intoNixOS:masterfrom
PaulGrandperrin:pd
Sep 2, 2025
Merged

perfect_dark: init at 0-unstable-2025-08-25#306767
SigmaSquadron merged 2 commits intoNixOS:masterfrom
PaulGrandperrin:pd

Conversation

@PaulGrandperrin
Copy link
Contributor

@PaulGrandperrin PaulGrandperrin commented Apr 25, 2024

Description of changes

A PC port of Perfect Dark based on the decompilation of the Nintendo 64 game

https://github.com/fgsfdsfgs/perfect_dark

To play the game, you need to put the corresponding ROM at $XDG_DATA_HOME/perfectdark/data/pd.ntsc-final.z64 and then nix run github:NixOS/nixpkgs/pull/306767/head#pd.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@PaulGrandperrin PaulGrandperrin changed the title pd: init at b4f7f467c New package: pd (PC port of Perfect Dark) Apr 25, 2024
@PaulGrandperrin PaulGrandperrin marked this pull request as ready for review April 25, 2024 12:43
@yunfachi
Copy link
Member

yunfachi commented Apr 25, 2024

In 35c30e19cd7a46597f336a08b1d9509a0fb4ba53 you add yourself as a maintainer, but this should be in a separate commit with the message: maintainers: add <handle>.

Also change the pull-request title to pd: init at <version>.

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Apr 25, 2024
@PaulGrandperrin PaulGrandperrin changed the title New package: pd (PC port of Perfect Dark) pd: init at b4f7f467c Apr 25, 2024
@PaulGrandperrin
Copy link
Contributor Author

@yunfachi It's done!

Sorry, I missed that the commit needed to be split.. that makes sense actually :)

@PaulGrandperrin
Copy link
Contributor Author

Upstream just accepted a PR I sent them, so I updated this PR too to remove the patch I had to carry.

@PaulGrandperrin PaulGrandperrin changed the title pd: init at b4f7f467c pd: init at a0f855003 Apr 25, 2024
@PaulGrandperrin PaulGrandperrin changed the title pd: init at a0f855003 pd: init at 0-unstable-2024-04-25 Apr 26, 2024
@PaulGrandperrin
Copy link
Contributor Author

@qubitnano I'll create a new commit to make more changes.

What do you think about the name pd? That's what upstream uses for the binary, but the repo is named "perfect_dark".

Perfect Dark is trademarked by Microsoft.

@PaulGrandperrin PaulGrandperrin force-pushed the pd branch 2 times, most recently from bdef7c2 to 4b6bed3 Compare April 26, 2024 12:09
@PaulGrandperrin
Copy link
Contributor Author

I now pushed a new squashed commit taking into account all the suggestions.
The version has been updated in the commit message and this PR title.

Everyone is happy with the name pd?

@yunfachi
Copy link
Member

yunfachi commented Apr 26, 2024

Everyone is happy with the name pd?

I would prefer perfect-dark, but I won't insist.
You can read https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-naming to make a choice.
In addition, please consider the ripgrep package, which has a single executable rg, but is called ripgrep.

@PaulGrandperrin
Copy link
Contributor Author

You can read https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-naming to make a choice.

I read that part but it doesn't clear the ambiguity of this situation. And doesn't talk about potential trademark issues.

That kind of projects already make many people anxious with respect to legality.

For instance, the decomp of Ocarina of Time explicitly avoids any references to "Zelda" or "Ocarina of Time".

I really don't like pd (it's slang for fagg*t in french) but I thought maintainers might push back on perfect_dark.

@PaulGrandperrin
Copy link
Contributor Author

PaulGrandperrin commented Apr 26, 2024

Also, the project says its license is MIT but I'm not even sure it's legal.

It's obviously a derivative work of an unfree piece of software, so I don't really believe it can be MIT.

I think it's important for us because if we mark it as free, its source and binary will be stored and distributed on cache.nixos.org.

This might become a source of pain if Microsoft decides to sue the project in the future, similarly to yuzu.

EDIT: For reference, sm64 and shipwright upstream projects don't have a license (and I think it makes sense) and are therefore considered unfree by NixOS.

@pluiedev
Copy link
Member

You can read https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-naming to make a choice.

I read that part but it doesn't clear the ambiguity of this situation. And doesn't talk about potential trademark issues.

That kind of projects already make many people anxious with respect to legality.

For instance, the decomp of Ocarina of Time explicitly avoids any references to "Zelda" or "Ocarina of Time".

I really don't like pd (it's slang for fagg*t in french) but I thought maintainers might push back on perfect_dark.

The thing for me is that it kinda overly obscures what it's for, and usually shorter names are reserved for more 'fundamental' tools like ar and cc, and it's kinda silly to me that Perfect Dark gets to have pd purely to disguise it from Nintendo's eyes. Really, if that's the sole purpose, then there needs to be a formal policy drafted regarding the status of Nintendo property, or other pieces of software that could contain Nintendo property, on Nixpkgs.

Thankfully, the worst you can do is to have one or maybe several repos in nix-community that contain these packages, away from Big N's eyes... 👀

@pluiedev
Copy link
Member

pluiedev commented Apr 26, 2024

Also, the project says its license is MIT but I'm not even sure it's legal.

It's obviously a derivative work of an unfree piece of software, so I don't really believe it can be MIT.

I think it's important for us because if we mark it as free, its source and binary will be stored and distributed on cache.nixos.org.

This might become a source of pain if Microsoft decides to sue the project in the future, similarly to yuzu.

EDIT: For reference, sm64 and shipwright upstream projects don't have a license (and I think it makes sense) and are therefore considered unfree by NixOS.

I am decidedly NOT a lawyer, but judging by the fact the repo contains reverse-engineered code that still compiles to the original binary, I think it would be easier to make the case that the repo contains the original developer's code and cannot be re-licensed under the MIT license by the reverse engineer. However, this is an upstream issue and for now we should follow what's written on the tin.

Maybe add a generic unfree license in the mix of licenses so that it's marked as unfree software with (possibly) FOSS parts?

@PaulGrandperrin
Copy link
Contributor Author

PaulGrandperrin commented Apr 26, 2024

The thing for me is that it kinda overly obscures what it's for, and usually shorter names are reserved for more 'fundamental' tools like ar and cc, and it's kinda silly to me that Perfect Dark gets to have pd purely to disguise it from Nintendo's eyes. Really, if that's the sole purpose, then there needs to be a formal policy drafted regarding the status of Nintendo property, or other pieces of software that could contain Nintendo property, on Nixpkgs.

Thankfully, the worst you can do is to have one or maybe several repos in nix-community that contain these packages, away from Big N's eyes... 👀

Oh, it's really not about hiding it, or that there exists mentions of it in the project. We can mention trademark and registered name as much as we want. But naming a piece of software with a registered name, that's exactly what registering a name is supposed to protect from.

For instance, the shipwright project is careful about not naming their project with a trademarked name but "Zelda" and "Ocarina of Time" are present hundreds of times in the source code and assets. Also, everyone knows what they are about, including Nintendo, so they're not hiding from anything.

The issue I see here, is officially presenting this piece of software with a trademarked name that we don't own or have a license for.

I think the shipwright project have the exact same understanding of the situation as me on this. They and I can be wrong as IANAL.

@SigmaSquadron SigmaSquadron dismissed Atemu’s stale review August 26, 2025 02:55

This review is now outdated, as it has become clear that the potential legal issues with upstream will not affect us, as derivations are generally not considered to be derivative works of a project.

@nixpkgs-ci nixpkgs-ci bot removed the 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. label Aug 26, 2025
@nix-owners nix-owners bot requested a review from philiptaron August 26, 2025 02:58
Copy link

@j0lol j0lol left a comment

Choose a reason for hiding this comment

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

LGTM!

@ghost
Copy link

ghost commented Aug 26, 2025

More changes

  • Elaborate on the comment above the patch for the desktop file.
  • Make installPhase more consistently written. Also put the PNG icon in 256x256 and not in scalable.
  • Fix error in meta.longDescription that referred to the previous pd attribute.
  • Rewrite meta.longDescription to be more concise.
  • Since unfree was commented out, remove the comment from meta.license

@SigmaSquadron

diff --git a/pkgs/by-name/pe/perfect_dark/package.nix b/pkgs/by-name/pe/perfect_dark/package.nix
index 0c5fc63652de..875980016495 100644
--- a/pkgs/by-name/pe/perfect_dark/package.nix
+++ b/pkgs/by-name/pe/perfect_dark/package.nix
@@ -54,7 +54,8 @@ stdenv.mkDerivation (finalAttrs: {
         --replace-fail "git rev-parse --abbrev-ref HEAD" \
                        "echo port"
     ''
-    # Point toward the compiled binary and not the shell wrapper.
+    # Point toward the compiled binary and not the shell wrapper since
+    # the rom auto-detection logic is not needed in this build.
     + ''
       substituteInPlace dist/linux/io.github.fgsfdsfgs.perfect_dark.desktop \
         --replace-fail "Exec=io.github.fgsfdsfgs.perfect_dark.sh" \
@@ -77,17 +78,17 @@ stdenv.mkDerivation (finalAttrs: {

   installPhase = ''
     runHook preInstall
-    pushd ..

+    pushd ..
     install -Dm755 build/pd.* $out/bin/io.github.fgsfdsfgs.perfect_dark
     install -Dm644 dist/linux/io.github.fgsfdsfgs.perfect_dark.desktop \
-            -t $out/share/applications/
+            -t $out/share/applications
     install -Dm644 dist/linux/io.github.fgsfdsfgs.perfect_dark.png \
-            -t $out/share/icons/hicolor/scalable/apps/
+            -t $out/share/icons/hicolor/256x256/apps
     install -Dm644 dist/linux/io.github.fgsfdsfgs.perfect_dark.metainfo.xml \
-            -t $out/share/metainfo/
-
+            -t $out/share/metainfo
     popd
+
     runHook postInstall
   '';

@@ -98,18 +99,16 @@ stdenv.mkDerivation (finalAttrs: {
       shooter Perfect Dark to modern systems.

       You'll need to provide a copy of the ROM at
-      `$HOME/.local/share/perfectdark/data/pd.${romID}.z64`
-      to launch the game.
-
-      You can also change the ROM variant of this game with an
-      expression like this:
+      `$HOME/.local/share/perfectdark/data/pd.${romID}.z64` to launch
+      the game.

-      `pd.override { romID = "jpn-final" }`
+      Though `ntsc-final` is the recommended default, you can change
+      the ROM variant of this game via an override like so:

-      Supported romIDs are `${lib.generators.toPretty { } roms}`.
+      `perfect_dark.override { romID = "jpn-final"; }`

-      `ntsc-final` the default as it is the only recommended one by
-      upstream.
+      Supported `romID` values are are `${lib.generators.toPretty { }
+      roms}`.
     '';
     homepage = "https://github.com/fgsfdsfgs/perfect_dark/";
     license = with lib.licenses; [
@@ -117,10 +116,6 @@ stdenv.mkDerivation (finalAttrs: {
       mit
       # tools/mkrom/gzip
       gpl3Plus
-      # The project's original work is licensed under MIT, but a lot of
-      # it can be seen as a derivative work of an unfree piece of
-      # software. We account for that here.
-      # unfree
     ];
     maintainers = with lib.maintainers; [
       PaulGrandperrin

@emilazy
Copy link
Member

emilazy commented Aug 26, 2025

I don’t want to wade into the discussion about whether this constitutes warez we shouldn’t be trying to package at all, but there is seriously no way we can merge a derivative work of a byte‐for‐byte decompilation as lib.licenses.free and built on Hydra. It must be lib.licenses.unfree.

@Pandapip1
Copy link
Member

Or meta.hydraPlatforms = [ ];, which might be more appropriate here.

@emilazy
Copy link
Member

emilazy commented Aug 26, 2025

meta.hydraPlatforms is not reliable enough – any other job can still pull it in and get it built and cached.

If this was packaging the original decompilation and not a modified fork, then the output produced by building it would be bit‐for‐bit identical to the copyrighted executable code in the original game. I really don’t think there’s any argument for the outputs of this derivation not being encumbered by proprietary copyright.

@SigmaSquadron
Copy link
Contributor

Oh, sorry, that was my bad. This is supposed to be unfree, and I forgot to remove the comment.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. and removed 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Aug 26, 2025
@SigmaSquadron SigmaSquadron force-pushed the pd branch 2 times, most recently from 9ba2736 to 7901c55 Compare August 27, 2025 08:39
@ghost
Copy link

ghost commented Aug 27, 2025

suggestion (non-blocking): Rewrite unfree comment to be concise

diff --git a/pkgs/by-name/pe/perfect_dark/package.nix b/pkgs/by-name/pe/perfect_dark/package.nix
index dcffb421d8eb..3c3b598551c1 100644
--- a/pkgs/by-name/pe/perfect_dark/package.nix
+++ b/pkgs/by-name/pe/perfect_dark/package.nix
@@ -116,9 +116,7 @@ stdenv.mkDerivation (finalAttrs: {
       mit
       # tools/mkrom/gzip
       gpl3Plus
-      # The project's original work is licensed under MIT, but a lot of
-      # it can be seen as a derivative work of an unfree piece of
-      # software. We account for that here.
+      # Derivative work of "Perfect Dark" (C) 2000 RARE Ltd.
       unfree
     ];
     maintainers = with lib.maintainers; [

I think having this licensing comment would be more concise and informative as it references the copyright holder by name instead of being vague ("it can be seen", "we account for 'that'")

Copy link
Contributor

@qubitnano qubitnano left a comment

Choose a reason for hiding this comment

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

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 306767
Commit: e8808468d434f582bea786c21a06e43c0352b6d1


x86_64-linux

✅ 1 package built:
  • perfect_dark

A PC port of Perfect Dark based on the decompilation of the Nintendo 64 game

Co-authored-by: Jasi <normalc@posteo.net>
Co-authored-by: Fernando Rodrigues <alpha@sigmasquadron.net>
Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net>
@PaulGrandperrin
Copy link
Contributor Author

I went through all the comments and changes and this is great!

There's only one thing that annoys me, the "qualified application domain name" io.github.fgsfdsfgs.perfect_dark.

@normalcea wouldn't perfect_dark be fine with you? It would be a lot more intuitive when launching the game from the cmdline.

@PaulGrandperrin
Copy link
Contributor Author

About the conversation about the "unfree" license, I just want to add that we had a similar conversation at the beginning of the PR and that we came to the same conclusion: hydra should never build this package and that an "unfree" license both achieved this goal and made sense in and of itself.

@ghost
Copy link

ghost commented Sep 1, 2025

I went through all the comments and changes and this is great!

There's only one thing that annoys me, the "qualified application domain name" io.github.fgsfdsfgs.perfect_dark.

@normalcea wouldn't perfect_dark be fine with you? It would be a lot more intuitive when launching the game from the cmdline.

This ultimately isn't that much of an issue because meta.mainProgram is set to this executable so it will be discovered by command line users. Users themselves can just alias this name to whatever name they want in their shell.

Also this would involve also having to patch the desktop file as well and not just the executable which just adds more noise to the derivation to solve an issue that isn't ours to solve.

'';

preConfigure = ''
patchShebangs --build .
Copy link

@ghost ghost Sep 1, 2025

Choose a reason for hiding this comment

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

Suggested change
patchShebangs --build .
patchShebangs --build tools/assetmgr

(non-blocking): Don't recursively patch all files in source, but only the files we need for building.

Copy link

@ghost ghost Sep 1, 2025

Choose a reason for hiding this comment

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

These types of changes can be done in a follow-up PR, but it doesn't hurt to document them here for reference.

Copy link
Member

@keenanweaver keenanweaver left a comment

Choose a reason for hiding this comment

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

Game playing as expected on x86_64-linux. Compiled and played with all three supported ROM regions.

Did not test aarch64.

nixpkgs-review result for #306767

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 306767
Commit: cad17194fe73ab224313a157856c08a36bcbf15e (subsequent changes)
Merge: 967262ac17224e11c5604a847c7d9b9d7c7db1c5

Logs: https://github.com/keenanweaver/nixpkgs-review-gha/actions/runs/17384040207


x86_64-linux

✅ 1 package built:
  • perfect_dark

aarch64-linux

✅ 1 package built:
  • perfect_dark

@SigmaSquadron
Copy link
Contributor

Thank you everyone for sticking around through such a turbulent PR. It should now be easier to collaboratively make changes to this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.severity: legal This PR or issue raises or fixes a legal issue, e.g. licensing compliance 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 3+ This PR was reviewed and approved by three or more persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.