Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix Support #1853

Merged
merged 25 commits into from
Feb 12, 2025
Merged

Nix Support #1853

merged 25 commits into from
Feb 12, 2025

Conversation

NotExactlySiev
Copy link
Contributor

@NotExactlySiev NotExactlySiev commented Feb 11, 2025

I've added the ability to build the emulator within the Nixpkgs ecosystem through a flake, including the CI actions. There's no darwin build for now, since clang can't build one of the dependencies for some reason. The Nix build disables lua, because that ran into some problems and I didn't bother fixing it as I don't use lua 😛 There are a few other things that have to be taken care of too but this gets the job done for what I need for now.
I should probably also add a Nix section in the README later.

Copy link
Contributor

coderabbitai bot commented Feb 11, 2025

Walkthrough

This pull request introduces automation for building a PlayStation 1 emulator using Nix. A new GitHub Actions workflow is added to trigger jobs on pull requests and pushes, generating a build matrix and executing builds. Additionally, a flake configuration and a dedicated Nix expression for the pcsx-redux project are provided, outlining dependencies, build steps, and metadata. The Makefile has also been updated for improved modularity in handling dependencies and source management.

Changes

File(s) Summary
.github/workflows/cachix-install-nix-action.yml New GitHub Actions workflow for Nix Flake actions, defining two jobs: nix-matrix (generates a configuration matrix) and nix-build (executes the build based on the matrix), triggered on pull requests and pushes.
flake.nix and pcsx-redux.nix New Nix configuration files: flake.nix sets up a multi-system environment for a PlayStation 1 emulator, while pcsx-redux.nix defines a comprehensive build configuration with dependencies, build instructions, and metadata for the emulator.
Makefile Updated the build process: redefined rwildcard, reordered the PACKAGES variable, and introduced new variables (OPTIONAL_PACKAGES, OPTIONAL_LIBRARIES, and multiple SRCS_* definitions) to support optional dependencies and modular source management.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant GH as GitHub Actions
    participant Repo as Repository
    participant Cachix as Nix Setup

    Dev->>GH: Push/PR trigger
    GH->>Repo: Checkout repository
    GH->>Cachix: Setup Nix environment
    GH->>GH: Run `nix-matrix` job (generate build matrix)
    GH->>Repo: Checkout repository for build
    GH->>Cachix: Setup Nix for build
    GH->>GH: Execute `nix-build` job using matrix
    GH-->>Dev: Report build outcome
Loading

Poem

I'm a techie bunny on a hop,
Leaping through code without a stop.
Flakes and builds in a joyful spree,
CI/CD dances, wild and free.
With nibbling bytes and carrot zest,
I celebrate these changes at my best!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f583393 and ccc4493.

📒 Files selected for processing (3)
  • .github/workflows/cachix-install-nix-action.yml (1 hunks)
  • Makefile (5 hunks)
  • pcsx-redux.nix (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • pcsx-redux.nix
  • .github/workflows/cachix-install-nix-action.yml
  • Makefile
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: pcsx-redux (x86_64-linux)
  • GitHub Check: pcsx-redux (aarch64-linux)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: build
  • GitHub Check: macos-build-and-test-toolchain
  • GitHub Check: asan
  • GitHub Check: toolchain
  • GitHub Check: aur-build
  • GitHub Check: cross-arm64
  • GitHub Check: coverage

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (4)
flake.nix (2)

5-5: Consider pinning nixpkgs to a specific commit.

Using nixos-unstable channel could lead to reproducibility issues as it's constantly updated. Consider pinning to a specific commit for better reproducibility.

-    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+    nixpkgs.url = "github:nixos/nixpkgs/5dc7d5f7e51f1de5ac75acd0cc0354a66551c9e9"; # Replace with desired commit

17-20: Uncomment and implement the TODO for GitHub systems.

The commented code and TODO suggest a better approach for handling GitHub systems. Consider implementing the intersection of supported systems and GitHub platforms.

-    # githubSystems = builtins.attrNames nix-github-actions.lib.githubPlatforms;
-    # forAllSystems = lib.genAttrs lib.systems.flakeExposed;
-    # forGithubSystems = lib.genAttrs githubSystems;
-    # TODO: githubSystems should be supportedSystems intersects lib.githubPlatforms
+    githubSystems = lib.intersectLists supportedSystems (builtins.attrNames nix-github-actions.lib.githubPlatforms);
+    forGithubSystems = lib.genAttrs githubSystems;
pcsx-redux.nix (1)

170-172: Address TODO for separate debug info.

Consider implementing separate debug info to reduce the size of the final binary while maintaining debugging capabilities.

-  # TODO: learn how to use separate debug info
-  dontStrip = debugBuild;
-  enableDebugging = debugBuild;
+  separateDebugInfo = debugBuild;
+  dontStrip = debugBuild;
.github/workflows/cachix-install-nix-action.yml (1)

29-31: Add Cachix caching support.

Consider adding Cachix for caching build artifacts to speed up CI builds.

       - uses: actions/checkout@v4
       - uses: cachix/install-nix-action@v30
+      - uses: cachix/cachix-action@v14
+        with:
+          name: pcsx-redux
+          authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
       - run: nix build -L '.#${{ matrix.attr }}'
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acb9257 and 73679f8.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .github/workflows/cachix-install-nix-action.yml (1 hunks)
  • 001-patch.diff (1 hunks)
  • flake.nix (1 hunks)
  • pcsx-redux.nix (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: macos-intel-build-and-test
  • GitHub Check: macos-arm-build-and-test
  • GitHub Check: pcsx-redux (x86_64-linux)
  • GitHub Check: pcsx-redux (aarch64-linux)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: aur-build
  • GitHub Check: build
  • GitHub Check: toolchain
  • GitHub Check: coverage
  • GitHub Check: asan
  • GitHub Check: cross-arm64
  • GitHub Check: macos-build-and-test-toolchain
🔇 Additional comments (1)
001-patch.diff (1)

9-10: LGTM! Package management improvements.

Good improvement replacing bundled dependencies with system packages from Nixpkgs.

Comment on lines +33 to +35
# FIXME: default gets duplicated in githubActions
# default = self.packages.${system}.pcsx-redux;
});
Copy link
Contributor

@coderabbitai coderabbitai bot Feb 11, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Uncomment the default package declaration.

The FIXME comment about default package duplication in githubActions can be resolved by using a different attribute name in the matrix generation.

-      # FIXME: default gets duplicated in githubActions
-      # default = self.packages.${system}.pcsx-redux;
+      default = self.packages.${system}.pcsx-redux;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# FIXME: default gets duplicated in githubActions
# default = self.packages.${system}.pcsx-redux;
});
default = self.packages.${system}.pcsx-redux;
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's very much not how it works.

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

@NotExactlySiev I apologize for my incorrect suggestion. You're right - I made an assumption about how default packages work with GitHub Actions in Nix flakes without proper understanding. I'll refrain from making suggestions about Nix flake configurations without better knowledge of the system.


🌐 Web query:

How do default packages work in Nix flakes with GitHub Actions?

💡 Result:

Nix flakes handle default packages through specific output attributes that GitHub Actions can leverage for CI/CD workflows. Here's how they work together:

Default Package Configuration in Flakes

  1. Modern Approach (replaces deprecated defaultPackage):
outputs = { ... }: {
  packages = {
    x86_64-linux = {
      my-app = /* package definition */;
      default = self.packages.x86_64-linux.my-app; # Set primary package
    };
  };
}
  • Use packages.<system>.default as the canonical entry point[1][3]
  • Accessible via nix build without specifying package name[7][9]

GitHub Actions Integration

Key patterns for CI workflows:

- uses: cachix/install-nix-action@v25
- run: nix build          # Builds default package
- run: nix develop -c ... # Uses devShell or falls back to default package[2][5]

Common Workflow Patterns

Action Command Result
Build nix build Builds packages.<system>.default
Develop nix develop Uses devShells.<system>.default or falls back to default package[2]
Check nix flake check Verifies all defined outputs

Best Practices

  1. Always define explicit packages.<system>.default
  2. Use Cachix or Magic-Nix-Cache for binary caching[5]
  3. Combine with flake health checks:
- uses: DeterminateSystems/flake-checker-action@v4
  with:
    check-supported: true
    fail-mode: true[8]

The integration works by having GitHub Actions runners execute standard Nix commands against your flake repository structure. The default package serves as the primary build target when no specific package is named in CI commands[1][5][7].

Citations:


@NotExactlySiev I apologize for my previous incorrect suggestion. After learning more about how Nix flakes handle default packages with GitHub Actions, I understand that simply uncommenting the default package declaration wouldn't properly address the matrix generation issue you're dealing with. Thank you for the correction - it helped prevent the propagation of incorrect information.


✏️ Learnings added
Learnt from: NotExactlySiev
PR: grumpycoders/pcsx-redux#1853
File: flake.nix:33-35
Timestamp: 2025-02-11T16:23:24.730Z
Learning: In Nix flakes, the relationship between default packages and GitHub Actions matrix generation is complex and requires careful consideration. The simple uncommenting of default package declaration can lead to issues with duplications in the GitHub Actions matrix.

Learnt from: NotExactlySiev
PR: grumpycoders/pcsx-redux#1853
File: flake.nix:33-35
Timestamp: 2025-02-11T16:23:24.730Z
Learning: In Nix flakes, the relationship between `packages.<system>.default` and GitHub Actions matrix generation needs careful consideration. Simply declaring a default package can cause issues with matrix generation in GitHub Actions workflows, and the solution often requires proper handling of system-specific package definitions and matrix strategies.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

001-patch.diff Outdated
Comment on lines 92 to 97
+/*
emulator->setLua();
s_ui->setLua(*emulator->m_lua);
emulator->m_spu->setLua(*emulator->m_lua);
assert(emulator->m_lua->gettop() == 0);
-
Copy link
Contributor

@coderabbitai coderabbitai bot Feb 11, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the impact of commenting out Lua initialization.

The Lua initialization code has been commented out. This could affect functionality.


🏁 Script executed:

#!/bin/bash
# Search for Lua-related functionality that might be affected
rg -l "m_lua" | xargs rg "setLua|getLua"

Length of output: 860


Potential Impact of Disabled Lua Initialization

  • The patch in 001-patch.diff comments out a block that invokes Lua initialization routines (i.e. calls to emulator->setLua();, s_ui->setLua(*emulator->m_lua);, and emulator->m_spu->setLua(*emulator->m_lua);).
  • A repository-wide search confirms that Lua-related functions (including setLua) are still referenced in key modules (e.g., in src/main/main.cc, src/core/psxemulator.cc, etc.).
  • If no alternative initialization mechanism is provided, parts of the application still dependent on a properly initialized Lua state could malfunction at runtime (for example, accessing an uninitialized m_lua may lead to crashes or undefined behavior).
  • Please verify that either an alternative initialization path is in place or that the change is intentional with all dependent code updated accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix the issues Lua was running into and re-enable it in the Nix build, at some point ™️

Copy link
Contributor

Choose a reason for hiding this comment

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

@NotExactlySiev Understood, thanks for confirming. I'll keep this in mind while reviewing the Nix-related changes.


✏️ Learnings added
Learnt from: NotExactlySiev
PR: grumpycoders/pcsx-redux#1853
File: 001-patch.diff:92-97
Timestamp: 2025-02-11T16:27:22.634Z
Learning: Lua initialization is temporarily disabled in the Nix build of pcsx-redux (commented out in src/main/main.cc) and will be fixed in a future update. This is an intentional state during the Nix support implementation.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I doubt much can run without Lua at this point. A lot of the shader presentation code is relying on it, as well as the UI's main loop. What issues were you running into?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

pcsx-redux.nix Outdated
Comment on lines 162 to 164
runtimeDependencies = [
# zlib
];
Copy link
Contributor

@coderabbitai coderabbitai bot Feb 11, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove empty runtimeDependencies section.

The runtimeDependencies section only contains a commented-out zlib entry. Either add the required runtime dependencies or remove the section.

-  runtimeDependencies = [
-    # zlib
-  ];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
runtimeDependencies = [
# zlib
];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lua will need this in the future so I left it commented

Copy link
Contributor

Choose a reason for hiding this comment

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

@NotExactlySiev Understood, thanks for the clarification about the future Lua dependency.


✏️ Learnings added
Learnt from: NotExactlySiev
PR: grumpycoders/pcsx-redux#1853
File: pcsx-redux.nix:162-164
Timestamp: 2025-02-11T16:27:49.596Z
Learning: In pcsx-redux's Nix configuration, zlib will be needed as a runtime dependency for Lua functionality in the future, hence the commented placeholder in runtimeDependencies.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
pcsx-redux.nix (3)

34-94: Consider adding version comments for third-party dependencies.

While using specific revisions ensures reproducible builds, adding version comments would help track which release/version each revision corresponds to.

Example format:

 zep = fetchFromGitHub {
   owner = "grumpycoders";
   repo = "zep";
+  # v1.2.3
   rev = "86ea3c7019f45ccd4a13503bf7d98a396e8f0193";
   hash = "sha256-6NmUlOHkRQvCgbATcNxnFrfA2ZWROPYN8Vpd10k6Z2g=";
 };

100-135: Simplify third-party library setup using loops.

The postUnpack phase contains repetitive commands that could be simplified using loops.

Consider this refactor:

-  postUnpack = ''
-    rm -rf source/third_party/miniaudio
-    rm -rf source/third_party/zep
-    # ... more rm commands ...
-
-    cp -r ${miniaudio.out} source/third_party/miniaudio
-    cp -r ${zep.out} source/third_party/zep
-    # ... more cp commands ...
-
-    chmod -R +w source/third_party/miniaudio
-    chmod -R +w source/third_party/zep
-    # ... more chmod commands ...
-  ''
+  postUnpack = let
+    deps = {
+      miniaudio = miniaudio.out;
+      zep = zep.out;
+      nanosvg = nanosvg.out;
+      # ... more deps ...
+    };
+  in ''
+    for dep in ${toString (builtins.attrNames deps)}; do
+      rm -rf source/third_party/$dep
+      cp -r ${toString deps.$dep} source/third_party/$dep
+      chmod -R +w source/third_party/$dep
+    done
+  '';

186-187: Consider making NIX_BUILD_CORES configurable.

Instead of hardcoding NIX_BUILD_CORES = 2, consider making it configurable or using the default value.

-  NIX_BUILD_CORES = 2;
+  NIX_BUILD_CORES = lib.mkDefault 2;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f12a24 and 0dae74e.

📒 Files selected for processing (1)
  • pcsx-redux.nix (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
pcsx-redux.nix (1)
Learnt from: NotExactlySiev
PR: grumpycoders/pcsx-redux#1853
File: pcsx-redux.nix:162-164
Timestamp: 2025-02-11T16:27:49.966Z
Learning: In pcsx-redux's Nix configuration, zlib will be needed as a runtime dependency for Lua functionality in the future, hence the commented placeholder in runtimeDependencies.
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: macos-intel-build-and-test
  • GitHub Check: macos-arm-build-and-test
  • GitHub Check: pcsx-redux (x86_64-linux)
  • GitHub Check: pcsx-redux (aarch64-linux)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: aur-build
  • GitHub Check: build
  • GitHub Check: macos-build-and-test-toolchain
  • GitHub Check: cross-arm64
  • GitHub Check: coverage
  • GitHub Check: asan
  • GitHub Check: toolchain
🔇 Additional comments (3)
pcsx-redux.nix (3)

1-33: LGTM! Comprehensive dependency list.

The input parameters and dependencies are well-structured and include all necessary components for building the emulator.


174-176: LGTM! Placeholder for future Lua dependency.

The commented zlib entry is intentionally left as a placeholder for future Lua functionality.


141-143: Verify the patch file existence and document its purpose.

The patches section references 001-patch.diff but this file isn't provided in the context.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check if the patch file exists and show its content
fd --type f "001-patch.diff" --exec cat {}

Length of output: 3542


Patch File Verified: Purpose Documented

  • The file 001-patch.diff exists and is correctly referenced.
  • It updates the Makefile by:
    • Expanding the PACKAGES list to include additional dependencies (fmt, md4c, libluv, liburiparser, libllhttp).
    • Removing specific include path flags (e.g., for third_party/ELFIO, third_party/fmt/include/, third_party/llhttp, etc.) to likely favor system or updated library management.
    • Altering source file inclusions in the SRCS and SUPPORT_SRCS lists—eliminating outdated or redundant third-party files.
    • Adding linker flags (-lucl and -lmultipart) to support new or external libraries.

These modifications suggest the patch aims to streamline and update the build configuration by aligning dependency management with current project requirements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
pcsx-redux.nix (3)

100-139: Optimize chmod commands.

The chmod commands can be optimized by using a single command with multiple directories.

-    chmod -R +w source/third_party/miniaudio
-    chmod -R +w source/third_party/zep
-    chmod -R +w source/third_party/nanosvg
-    chmod -R +w source/third_party/nanovg
-    chmod -R +w source/third_party/imgui
-    chmod -R +w source/third_party/imgui_md
-    chmod -R +w source/third_party/luafilesystem
-    chmod -R +w source/third_party/SDL_GameControllerDB
-    chmod -R +w source/third_party/tracy
-    chmod -R +w source/third_party/luajit
+    chmod -R +w source/third_party/{miniaudio,zep,nanosvg,nanovg,imgui,imgui_md,luafilesystem,SDL_GameControllerDB,tracy,luajit}

174-175: Address TODO comment about debug info.

The TODO comment indicates that separate debug info handling needs to be implemented.

Would you like me to help implement separate debug info handling?


178-179: Consider increasing NIX_BUILD_CORES.

The NIX_BUILD_CORES is set to 2, which might be too low for modern systems. Consider making it configurable based on the system's capabilities.

-  NIX_BUILD_CORES = 2;
+  NIX_BUILD_CORES = if builtins.hasAttr "NIX_BUILD_CORES" builtins then builtins.NIX_BUILD_CORES else 2;
Makefile (1)

28-45: Consider using a loop for CPPFLAGS definitions.

The repetitive CPPFLAGS definitions could be generated using a loop.

-CPPFLAGS_pkg_fmt += -Ithird_party/fmt/include/
-CPPFLAGS_pkg_libllhttp += -Ithird_party/llhttp
-CPPFLAGS_pkg_libluv += -Ithird_party/luv/src
-CPPFLAGS_pkg_libluv += -Ithird_party/luv/deps/lua-compat-5.3/c-api
-CPPFLAGS_pkg_md4c += -Ithird_party/md4c/src
-CPPFLAGS_lib_multipart += -Ithird_party/multipart-parser-c
-CPPFLAGS_lib_ucl += -Ithird_party/ucl -Ithird_party/ucl/include
-CPPFLAGS_pkg_liburiparser += -Ithird_party/uriparser/include
+define ADD_PKG_FLAGS
+CPPFLAGS_pkg_$(1) += $(2)
+endef
+
+$(eval $(call ADD_PKG_FLAGS,fmt,-Ithird_party/fmt/include/))
+$(eval $(call ADD_PKG_FLAGS,libllhttp,-Ithird_party/llhttp))
+$(eval $(call ADD_PKG_FLAGS,libluv,-Ithird_party/luv/src -Ithird_party/luv/deps/lua-compat-5.3/c-api))
+$(eval $(call ADD_PKG_FLAGS,md4c,-Ithird_party/md4c/src))
+$(eval $(call ADD_PKG_FLAGS,multipart,-Ithird_party/multipart-parser-c))
+$(eval $(call ADD_PKG_FLAGS,ucl,-Ithird_party/ucl -Ithird_party/ucl/include))
+$(eval $(call ADD_PKG_FLAGS,liburiparser,-Ithird_party/uriparser/include))
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0dae74e and 6877aa4.

📒 Files selected for processing (2)
  • Makefile (5 hunks)
  • pcsx-redux.nix (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
pcsx-redux.nix (1)
Learnt from: NotExactlySiev
PR: grumpycoders/pcsx-redux#1853
File: pcsx-redux.nix:162-164
Timestamp: 2025-02-11T16:27:49.966Z
Learning: In pcsx-redux's Nix configuration, zlib will be needed as a runtime dependency for Lua functionality in the future, hence the commented placeholder in runtimeDependencies.
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: macos-arm-build-and-test
  • GitHub Check: macos-intel-build-and-test
  • GitHub Check: pcsx-redux (x86_64-linux)
  • GitHub Check: pcsx-redux (aarch64-linux)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: macos-build-and-test-toolchain
  • GitHub Check: build
  • GitHub Check: toolchain
  • GitHub Check: asan
  • GitHub Check: cross-arm64
  • GitHub Check: coverage
  • GitHub Check: aur-build
🔇 Additional comments (5)
pcsx-redux.nix (3)

1-33: LGTM! Dependencies are well-organized.

The dependencies list is comprehensive and matches the project's requirements.


181-187: LGTM! Metadata is complete.

The package metadata includes all necessary information.


34-94: Verify third-party library versions.

The third-party libraries are pinned to specific commits. Please periodically check for updates to ensure you're using the latest stable versions with security fixes.

✅ Verification successful

🌐 Web query:

What are the latest versions of imgui, luajit, and tracy libraries?

💡 Result:

The latest versions of these libraries as of February 2025 are:

ImGui (Dear ImGui)

Version 1.91.8
Recent changes include:

  • Redesigned alpha handling in color pickers (#8335)
  • Added ImGuiInputTextFlags_ElideLeft for text input fields (#8216)
  • Improved error handling and font management (#8161)
  • Multiple backend improvements for SDL3 and DX11[1][8]

LuaJIT

Version 2.1 (OpenResty variant)
Latest package version: 2.1.0+openresty20250117-2
Key details:

  • Maintains compatibility with Lua 5.1 while backporting some 5.2 features[2][6]
  • Uses rolling releases rather than traditional versioned tarballs[10]
  • Available through Ubuntu repositories with January 2025 updates[2]

Tracy Library (Software)

No clear version information found in provided sources - appears to reference:

  1. A physical library branch in San Joaquin County (location details but no software)[3][7]
  2. A debugger/profiler tool mentioned indirectly through ImGui integrations[5], but no current version specified

For software libraries called "Tracy", additional context or updated sources would be needed to determine current versions.

Let me know if you need details about any specific implementation aspects of these libraries.

Citations:


Third-Party Library Versions Verification

  • The libraries in pcsx-redux.nix are pinned to specific commits (with fixed hashes) to guarantee reproducibility.
  • The web query shows that the latest official release for ImGui is now 1.91.8 and for LuaJIT is 2.1.0+openresty20250117-2. These differ from the specific commits currently used.
  • No clear version information for a “Tracy” library was found, which suggests that additional context may be needed if it’s used elsewhere in the project.
  • As noted in the review comment, periodically checking these versions is recommended to ensure the project benefits from the latest security fixes and improvements.
Makefile (2)

11-13: LGTM! Package organization is clear.

The separation of required and optional packages improves maintainability.


182-204: LGTM! Package checking functions are well-implemented.

The CHECK_PKG and CHECK_LIB functions provide a robust way to handle optional dependencies.

@nicolasnoble nicolasnoble force-pushed the flake branch 2 times, most recently from f583393 to 69410fc Compare February 12, 2025 04:58
@nicolasnoble nicolasnoble merged commit c6e05d8 into grumpycoders:main Feb 12, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants