Skip to content

Nix: Add OpenBIOS to the build and refactor derivation#1923

Merged
nicolasnoble merged 17 commits into
grumpycoders:mainfrom
NotExactlySiev:nix-openbios
Apr 15, 2025
Merged

Nix: Add OpenBIOS to the build and refactor derivation#1923
nicolasnoble merged 17 commits into
grumpycoders:mainfrom
NotExactlySiev:nix-openbios

Conversation

@NotExactlySiev
Copy link
Copy Markdown
Contributor

The Nix build now ships with OpenBIOS. Also cleaned up the recipe a bit.
Also bumped up the number of build threads to 4, so the Github action build time has stayed the same even tho we're building the cross compiler too lol

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 11, 2025

Walkthrough

The changes update the Nix flake configuration and the pcsx-redux package build script. In flake.nix, package definitions now differentiate between legacy and cross-compilation imports (for the mipsel target) and explicitly set the default package as pcsx-redux. Additionally, GitHub Actions checks are revised to prevent double builds. In pcsx-redux.nix, individual GitHub submodule fetches are consolidated into a structured list with a new helper function fetchSubmodule, and build configurations have been refined with updated inputs, increased parallel cores, and conditional build flags.

Changes

File(s) Change Summary
flake.nix Modified package definitions to separate legacy and cross compilations (for mipsel-none-elf), added a default entry for pcsx-redux, and updated GitHub Actions checks to avoid double builds. Also updated the gccMips reference to use cross-compilation packages.
pcsx-redux.nix Consolidated multiple GitHub submodule fetches into a single structured submodules list and introduced the fetchSubmodule function. Updated build inputs to include zip, conditionally add gccMips based on the withOpenbios flag, increased NIX_BUILD_CORES to 4, and adjusted make/install flags accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant S as System
    participant FN as Flake.nix
    participant PKG as Package Manager
    S->>FN: Trigger build process
    FN->>PKG: Import legacy packages for ${system}
    FN->>PKG: Import cross packages (mipsel-none-elf)
    FN->>PKG: Set default package to pcsx-redux
    FN->>PKG: Update GitHub Actions to remove defaults
Loading
sequenceDiagram
    participant B as Build Process
    participant PX as pcsx-redux.nix
    participant SM as GitHub Submodule
    B->>PX: Initiate source unpacking
    PX->>PX: Iterate over submodules via fetchSubmodule
    PX->>SM: Request submodule details (owner, repo, revision, hash)
    SM-->>PX: Return submodule outputs
    PX->>B: Copy outputs and update build inputs
    B->>PX: Continue build with new configurations
Loading

Poem

I'm a bunny with a code-filled dream,
Hopping through flakes with a nimble scheme.
Cross-compiling carrots for a mipsel bite,
Submodules fetched, everything feels right.
In tunnels of build scripts, I happily play,
Celebrating clean changes in my quirky way! 🥕

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 0e6eda7 and 92d5c65.

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

27-33: Well-structured cross-compilation setup

The changes introduce a clear separation between regular packages (pkgs) and cross-compilation environment (cross). This structure improves maintainability by explicitly defining the cross-compilation target as "mipsel-none-elf", which is appropriate for PlayStation 1 development.


34-35: Explicitly defining the default package

Setting pcsx-redux as the default package is a good practice. It makes the intended primary package clear and simplifies usage for consumers of the flake.


39-39: Appropriate cross-compiler reference

Using cross.buildPackages.gccWithoutTargetLibc for the MIPS compiler is correct for this use case, as it provides the necessary toolchain without including target libraries that might conflict with OpenBIOS's custom environment.


44-47: Preventing redundant builds in CI

This change prevents GitHub Actions from building the same package twice by removing the default attribute. This is an efficiency improvement that avoids wasting CI resources.

pcsx-redux.nix (8)

29-29: Added required dependencies for OpenBIOS

The addition of zip as a dependency and the new withOpenbios parameter are appropriate for supporting the OpenBIOS build process.

Also applies to: 35-35


39-104: Excellent refactoring of submodule management

The consolidation of individual fetchFromGitHub calls into a structured submodules list significantly improves code organization and maintainability. The conditional inclusion of platform-specific and OpenBIOS-specific repositories using lib.optional is elegant and follows Nix best practices.


106-108: Good utility function for DRY implementation

The fetchSubmodule function eliminates repetitive code by encapsulating the fetching and copying logic. This follows the DRY (Don't Repeat Yourself) principle and makes the code more maintainable.


114-117: Streamlined post-unpack process

The updated postUnpack phase effectively uses the new fetchSubmodule function with concatStringsSep to process all submodules in a clean, functional manner.


122-127: Well-structured conditional dependencies

The conditional inclusion of MIPS compiler tools and zip when withOpenbios is enabled is appropriate. Unwrapping the compiler components ensures they're directly accessible during the build process.


153-157: Improved make flags with conditional OpenBIOS build

The updated makeFlags correctly includes the OpenBIOS target conditionally, along with necessary prefix settings for the MIPS cross-compiler.


159-163: Properly separated install flags

Separating installFlags from makeFlags improves clarity and follows standard Nix practice. The conditional inclusion of "install-openbios" is consistent with the overall approach to making OpenBIOS support optional.


170-170: Appropriate build parallelism increase

Increasing NIX_BUILD_CORES from 2 to 4 aligns with the PR objective to maintain build performance despite the added complexity of the cross-compiler and OpenBIOS.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@nicolasnoble nicolasnoble requested a review from Copilot April 15, 2025 03:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • flake.nix: Language not supported
  • pcsx-redux.nix: Language not supported

@nicolasnoble nicolasnoble enabled auto-merge April 15, 2025 03:49
@nicolasnoble nicolasnoble merged commit 93ae066 into grumpycoders:main Apr 15, 2025
22 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 6, 2025
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.

3 participants