Skip to content

nix: Fix submodules#1953

Merged
nicolasnoble merged 1 commit intogrumpycoders:mainfrom
cleverca22:fix-submodules
Aug 8, 2025
Merged

nix: Fix submodules#1953
nicolasnoble merged 1 commit intogrumpycoders:mainfrom
cleverca22:fix-submodules

Conversation

@cleverca22
Copy link
Copy Markdown
Contributor

this PR switches the flakes from using submodules manually (which can also break due to NixOS/nix#13698 )
over to using submodules via flakes (which then also needs nix to be upgraded)

this is required, because fetching the project via a flake URI such as nix build github:grumpycoders/pcsx-redux/1b0cbe5e4a535def2e3e3279551e6665cdc102ae completely breaks the build
which also makes it impossible to add this project as an input on another flake

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 6, 2025

Walkthrough

The change updates the pcsx-redux.nix build script to use the cp -ruT command instead of cp -ru when copying submodules and dependencies into the third_party directory. It also removes a commented-out line for NIX_BUILD_CORES and cleans up a trailing blank line.

Changes

Cohort / File(s) Change Summary
Nix build script adjustments
pcsx-redux.nix
Updated cp command flags from -ru to -ruT for submodule and dependency copying; removed a commented-out NIX_BUILD_CORES line and cleaned up a trailing blank line.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Poem

A rabbit hops through Nix with glee,
Tweaking flags for cp with care and esprit.
No more stray comments or trailing space,
The build script's tidy, in its rightful place.
With -ruT in paw, I bound ahead—
Clean code and carrots, both well-fed! 🥕

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 d5dea0a and 2bc000e.

📒 Files selected for processing (1)
  • pcsx-redux.nix (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • pcsx-redux.nix
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: pcsx-redux (aarch64-linux)
  • GitHub Check: pcsx-redux (x86_64-linux)
  • GitHub Check: build
  • GitHub Check: toolchain
  • GitHub Check: macos-build-and-test-toolchain
  • GitHub Check: coverage
  • GitHub Check: cross-arm64
  • GitHub Check: aur-build
  • GitHub Check: asan
  • GitHub Check: build-openbios
  • GitHub Check: Codacy Static Code Analysis
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @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.

@cleverca22
Copy link
Copy Markdown
Contributor Author

ah crud!

git+https://github.com/cleverca22/pcsx-redux?ref=fix-submodules fetches the repo successfully, but silently ignores submodules
github:cleverca22/pcsx-redux/fix-submodules poisons the lock file, error: input attribute 'submodules' not supported by scheme 'github' and then you cant do anything to fix it, until you manually revert flake.lock

i'll need to revert the submodule improvements, and go for the backup fix

depending on how the repo is fetched, the submodule directories may not exist, or may be empty dirs
cp behaves differently if it exists, and -T is needed to force it to behave the same way
@nicolasnoble
Copy link
Copy Markdown
Member

@NotExactlySiev ping

@NotExactlySiev
Copy link
Copy Markdown
Contributor

Your solution works perfectly (thanks!) and could be merged in right now. However: those cp commands were meant to be only a temporary solution until I figure out a better way to do it. The correct solution imo would be to stop having those dependencies' paths be hardcoded to the third_party directory and instead modify the Makefile to receive their paths from an environment variable set by the derivation. This way the build can access these dependencies directly from the store without needing to copy anything. We already did something a bit like this in the Makefile for the luajit deps.

Also: I added NIX_BUILD_CORES = 4 because trying to build redux on my (16GB RAM + 16GB Swap) laptop causes the entire PC to hang for a few minutes before the build process crashes :P But I'm fine with removing it as I don't want other people who unlike me don't have limited RAM be forced into slow builds. Ideally there could be a check inside the derivation for the amount of available RAM before setting that variable, but I don't know how something like that will ever work within Nix's purity limits.
For now we can have it be unlimited by default and I'll just override it on my local system. But I expect a few other users to eventually run into the same problem and be confused as to why attempting to install pcsx-redux hangs their nix system 😛 So that's something we might have to think about.

@cleverca22
Copy link
Copy Markdown
Contributor Author

cleverca22 commented Aug 7, 2025

Also: I added NIX_BUILD_CORES = 4 because trying to build redux on my (16GB RAM + 16GB Swap) laptop

that should really be set in nix.conf
the way it is currently, it actively ignores my config, and i have to change the source to build with a different count
and because of the nix fetching bug, any change of the source fixed the problem, making it very hard to tell if it was a concurrency bug, due to it always using 4 threads

but yeah, nix itself doesnt have a good way to balance many small processes vs a few fat ones

@NotExactlySiev
Copy link
Copy Markdown
Contributor

that should really be set in nix.conf
ah that makes sense. wouldn't help in this case, as I usually have no issue building with 16 threads. it's just that compiling redux uses an unusually large amount of RAM per process due to heavy template use. still, manually overriding it for this one specific package works fine for me.
also due to the nature of the bug it was evading detection in the CI/CD checks so good catch!

@nicolasnoble
Copy link
Copy Markdown
Member

Note that I'm vendoring and pinning dependencies for a reason. Trying to use system packages where things are pinned and vendored is a bad idea. You break it, you buy it.

@nicolasnoble nicolasnoble enabled auto-merge August 8, 2025 04:30
@nicolasnoble nicolasnoble merged commit 4f4a00f into grumpycoders:main Aug 8, 2025
22 checks passed
@NotExactlySiev
Copy link
Copy Markdown
Contributor

We're still mostly using the vendored dependencies. it's just that nix likes to download them to /nix/store/<some random string> which then has to be copied into third_party. it would be nice if the build was able to address them where they're downloaded so we can avoid the copying.

@cleverca22 cleverca22 deleted the fix-submodules branch August 11, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants