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

feat: nix direnv #1367

Merged
merged 1 commit into from
Aug 6, 2024
Merged

feat: nix direnv #1367

merged 1 commit into from
Aug 6, 2024

Conversation

o-az
Copy link
Member

@o-az o-az commented Aug 6, 2024

Description

run direnv allow and all the nix packages in flake.nix will be injected into your shell

Testing

Explain the quality checks that have been done on the code changes

Additional Information

Your ENS/address:

esm.eth

Summary by CodeRabbit

  • New Features

    • Integrated Direnv for improved environment variable management.
    • Enhanced file association for .envrc with syntax highlighting in Visual Studio Code.
    • Added direnv to package dependencies for streamlined development setups.
  • Bug Fixes

    • Updated .gitignore to exclude .direnv files, improving project cleanliness.
  • Documentation

    • Updated recommended extensions in Visual Studio Code to support better Nix syntax.

Copy link

vercel bot commented Aug 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
tevm-monorepo-tevm ❌ Failed (Inspect) Aug 6, 2024 4:11am

Copy link

changeset-bot bot commented Aug 6, 2024

⚠️ No Changeset found

Latest commit: 8895ddb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Aug 6, 2024

Walkthrough

This update enhances the development environment by introducing a .envrc file for managing environment variables with Direnv, adding an entry to .gitignore to exclude .direnv, and updating Visual Studio Code configurations for a better developer experience. The flake.nix file is modified to include the Direnv package, streamlining the workflow for managing environment settings based on the current directory.

Changes

File Change Summary
.envrc Introduced to manage environment variables; includes use flake and sets DIRENV_WARN_TIMEOUT.
.gitignore Added .direnv to ignore list to prevent tracking of environment configurations in Git.
.vscode/extensions.json Replaced "antfu.vite" with "jeff-hykin.better-nix-syntax" for improved Nix syntax support.
.vscode/settings.json Added file association for .envrc to dotenv for better syntax highlighting in the editor.
flake.nix Included pkgs.direnv to package dependencies for managing environment variables.

Poem

🐰 In the burrow, changes bloom,
With .envrc, we make room.
Git ignores the cluttered mess,
While VS Code helps us progress.
Direnv hops in, smooth and bright,
Guiding us through day and night! 🌙✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@o-az o-az linked an issue Aug 6, 2024 that may be closed by this pull request
5 tasks
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 58698c8 and 8895ddb.

Files selected for processing (5)
  • .envrc (1 hunks)
  • .gitignore (1 hunks)
  • .vscode/extensions.json (1 hunks)
  • .vscode/settings.json (1 hunks)
  • flake.nix (1 hunks)
Files skipped from review due to trivial changes (4)
  • .envrc
  • .gitignore
  • .vscode/extensions.json
  • .vscode/settings.json
Additional comments not posted (2)
flake.nix (2)

26-26: LGTM! Addition of pkgs.direnv is appropriate.

The inclusion of direnv in the buildInputs list enhances the development environment by automatically managing environment variables based on the directory context.


Line range hint 30-34:
LGTM! shellHook configuration is correct.

The shellHook sets the prompt and sources a .env file if it exists, which is a standard practice for setting up the development environment.

@roninjin10 roninjin10 mentioned this pull request Aug 6, 2024
5 tasks
@roninjin10 roninjin10 merged commit 4ca121d into main Aug 6, 2024
7 of 8 checks passed
@roninjin10 roninjin10 deleted the nix-direnv branch August 6, 2024 04:17
@@ -23,6 +23,7 @@
pkgs.nodejs_22
pkgs.nodePackages.pnpm
pkgs.bun
pkgs.direnv
Copy link
Contributor

@shazow shazow Aug 6, 2024

Choose a reason for hiding this comment

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

Question: I haven't used direnv, but my understanding is that you need it installed outside of the flake so that it knows to activate the flake in the first place? If so, does it make sense to also include it as a dep inside the flake?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not fully sure @shazow. I've always had it installed globally.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it shouldn't be in here, it's kinda like including nix in here. :P

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yea agreed once you are in nix this becomes useless since you are already in mix

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO it shouldn't be in here, it's kinda like including nix in here. :P

this is a typical usage of direnv in nix. What do you mean like including nix?

One use case of direnv is you don't have to run nix develop if you use it. Also, your globally installed shell utilities remain available.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's what I mean, direnv already needs to be installed for this flake to be loaded, so it's moot to have the flake install it again? Similar to have nix already needs to be installed for this flake to be loaded.

Unless I don't understand how direnv works correctly. :)

Anyway it's not hurting anything, I just don't think it's helping anything either.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes good point. What I need to do is add instructions to getting started

# for direnv usage
nix shell nixpkgs#direnv
# then
direnv allow

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.

Nix improvements
3 participants