Skip to content

Fix setup #1709

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Fix setup #1709

wants to merge 4 commits into from

Conversation

0xgleb
Copy link
Collaborator

@0xgleb 0xgleb commented Apr 29, 2025

Motivation

  1. README.md setup instructions don't include the fact that the webapp package needs its own .env file that sets a value for PUBLIC_WALLETCONNECT_PROJECT_ID, without which prep-all.sh fails.
  2. Example .env file in packages/webapp was called env.example instead of .env.example
  3. VS Code/Cursor (and likely other editors) couldn't use Rust Analyzer provided by the Nix shell as they're not using the dev shell environment

Solution

  1. Add info about .env for the web app to the README.md instructions.
  2. Rename packages/webapp/env.example to packages/webapp/.env.example
  3. Add a Direnv config with nix-direnv. Assuming Direnv and Direnv VS Code plugin (or similar plugin for other editors) is installed, the editor can access the rust-analyzer binary from the Nix dev shell.
    • I can add a config file with extension recommendations to .vscode/ if that would be helpful.
    • I can also add Direnv setup instructions to README.
    • Alternatively, if you don't want to include any Direnv stuff, I can ignore all those and keep the config local.

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores

    • Added a .envrc file for improved environment management and automatic reloading on configuration changes.
    • Updated .gitignore to exclude the .direnv/ directory from version control.
    • Included .envrc in REUSE compliance configuration.
  • Documentation

    • Updated README with an additional step for setting up the webapp environment, including instructions for configuring the PUBLIC_WALLETCONNECT_PROJECT_ID.

Copy link
Contributor

coderabbitai bot commented Apr 29, 2025

"""

Walkthrough

This update introduces a new .envrc file for managing the development environment using a specific version of nix-direnv, adds .direnv/ to .gitignore to exclude environment-specific files from version control, and registers .envrc in REUSE.toml for license compliance tracking. The README is updated with an additional setup instruction for configuring the webapp environment by copying and editing an .env file.

Changes

File(s) Change Summary
.envrc Added new file to enforce use of nix-direnv version 3.0.6, source configuration, and manage environment reloads.
.gitignore Updated to ignore the .direnv/ directory.
README.md Added a new environment setup step for the webapp, instructing users to copy and edit .env file.
REUSE.toml Registered .envrc in the list of files for REUSE license compliance.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant direnv
    participant nix-direnv
    participant GitHub (nix-community)

    Developer->>direnv: Enter project directory
    direnv->>nix-direnv: Check nix_direnv_version
    alt Version unset or not 3.0.6
        nix-direnv->>GitHub (nix-community): Download [email protected] (verify SHA256)
        nix-direnv->>direnv: Source direnvrc
    end
    direnv->>nix-direnv: Watch flake.nix and flake.lock for changes
    direnv->>nix-direnv: Activate flake environment (verbose, trace)
Loading
sequenceDiagram
    participant Developer
    participant README.md

    Developer->>README.md: Read setup instructions
    README.md-->>Developer: Instruct to copy .env.example to .env
    Developer->>Developer: Fill PUBLIC_WALLETCONNECT_PROJECT_ID with test ID
Loading

"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d176f59 and 08ce7c8.

📒 Files selected for processing (4)
  • .envrc (1 hunks)
  • .gitignore (1 hunks)
  • README.md (1 hunks)
  • REUSE.toml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
.envrc (1)
Learnt from: 0xgleb
PR: rainlanguage/rain.orderbook#1709
File: .envrc:1-5
Timestamp: 2025-04-29T10:16:38.045Z
Learning: The `direnv` tool automatically monitors `.envrc` files for changes, so adding `watch_file .envrc` inside the `.envrc` file itself is redundant and unnecessary.
🔇 Additional comments (6)
.gitignore (1)

18-18: Properly excluding direnv generated files

Adding .direnv/ to the gitignore is the correct approach for preventing environment-specific files from being committed to version control when using direnv, which aligns with the PR objective of improving editor integration with the Nix development shell.

REUSE.toml (1)

5-5: Maintaining license compliance with new file

Properly registering the new .envrc file in the REUSE.toml ensures license compliance, which is important given the project's emphasis on REUSE 3.2 compliance as mentioned in the README.

README.md (1)

32-32: Good addition to environment setup instructions

This new step correctly addresses one of the primary objectives of the PR by documenting the requirement for the webapp .env file with the WalletConnect project ID. The sequential numbering is also correct.

.envrc (3)

1-5: Correct approach for conditional nix-direnv setup

The conditional check for nix-direnv version with secure hash verification is a best practice for ensuring consistent development environments across different machines.


7-8: Good configuration for automatic reloading

Setting up file watches for flake.lock and flake.nix ensures the environment is automatically reloaded when these important configuration files change, which improves the developer experience.


10-10: Appropriate flake activation command

Using use flake with the verbose and trace options helps with debugging if there are issues with the Nix environment, which is particularly helpful for a development setup.


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 generate sequence diagram to generate a sequence diagram of the changes in 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@0xgleb 0xgleb marked this pull request as ready for review April 29, 2025 10:11
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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ece3d12 and 038d20f.

📒 Files selected for processing (4)
  • .envrc (1 hunks)
  • .gitignore (1 hunks)
  • README.md (1 hunks)
  • REUSE.toml (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md

32-32: Ordered list item prefix
Expected: 3; Actual: 2; Style: 1/2/3

(MD029, ol-prefix)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
  • GitHub Check: git-clean
  • GitHub Check: test
  • GitHub Check: Deploy-Preview
  • GitHub Check: build-tauri (ubuntu-22.04, true)
  • GitHub Check: test
🔇 Additional comments (3)
.gitignore (1)

18-18: Appropriate addition of .direnv/ to .gitignore
Excluding the environment directory avoids committing machine-specific state. The pattern is correct and ensures .direnv/ and its contents are ignored.

REUSE.toml (1)

5-5: Register .envrc in REUSE.toml for license compliance
Adding .envrc ensures the new environment configuration file is covered by REUSE tooling. The entry aligns with the existing annotation list.

.envrc (1)

7-10: Watch flake files and activate the Nix flake environment
The calls to watch_file flake.lock, watch_file flake.nix, and use flake . are correct and will keep the environment in sync.

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 038d20f and d176f59.

📒 Files selected for processing (1)
  • README.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: test
  • GitHub Check: Deploy-Preview
  • GitHub Check: git-clean
  • GitHub Check: test
  • GitHub Check: test
🔇 Additional comments (1)
README.md (1)

32-32: Approve new webapp environment setup step.
The added step for copying packages/webapp/.env.example ensures that PUBLIC_WALLETCONNECT_PROJECT_ID is properly configured before running prep-all.sh.

Comment on lines 29 to 33

1. Copy `.env.example` to `.env`
2. Copy `tauri-app/.env.example` to `tauri-app/.env` and fill out `VITE_WALLETCONNECT_PROJECT_ID` with a test project ID from [Reown (FKA WalletConnect)](https://cloud.reown.com/sign-in)
3. Copy `packages/webapp/.env.example` to `packages/webapp/.env` and fill out `PUBLIC_WALLETCONNECT_PROJECT_ID` with a test project ID from [Reown (FKA WalletConnect)](https://cloud.reown.com/sign-in)

Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Suggest documenting Direnv activation.
Since this PR introduces an .envrc for nix-direnv, it’s helpful to add a note instructing users to run direnv allow so their shells and editors load the environment automatically. For example:

 ### Environment Setup
 1. Copy `.env.example` to `.env`
 2. Copy `tauri-app/.env.example` to `tauri-app/.env` and fill out `VITE_WALLETCONNECT_PROJECT_ID` with a test project ID from Reown (FKA WalletConnect)
 3. Copy `packages/webapp/.env.example` to `packages/webapp/.env` and fill out `PUBLIC_WALLETCONNECT_PROJECT_ID` with a test project ID from Reown (FKA WalletConnect)
+4. Run `direnv allow` in the project root to activate the Nix environment via `nix-direnv`.
📝 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
1. Copy `.env.example` to `.env`
2. Copy `tauri-app/.env.example` to `tauri-app/.env` and fill out `VITE_WALLETCONNECT_PROJECT_ID` with a test project ID from [Reown (FKA WalletConnect)](https://cloud.reown.com/sign-in)
3. Copy `packages/webapp/.env.example` to `packages/webapp/.env` and fill out `PUBLIC_WALLETCONNECT_PROJECT_ID` with a test project ID from [Reown (FKA WalletConnect)](https://cloud.reown.com/sign-in)
### Environment Setup
1. Copy `.env.example` to `.env`
2. Copy `tauri-app/.env.example` to `tauri-app/.env` and fill out `VITE_WALLETCONNECT_PROJECT_ID` with a test project ID from [Reown (FKA WalletConnect)](https://cloud.reown.com/sign-in)
3. Copy `packages/webapp/.env.example` to `packages/webapp/.env` and fill out `PUBLIC_WALLETCONNECT_PROJECT_ID` with a test project ID from [Reown (FKA WalletConnect)](https://cloud.reown.com/sign-in)
4. Run `direnv allow` in the project root to activate the Nix environment via `nix-direnv`.

@hardyjosh
Copy link
Contributor

@0xgleb please add the direnv setup instructions and config, sounds good. we can explain it's optional but helpful for devving

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