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

Init devenv, gitignore .nlsp-settings #1942

Merged
merged 3 commits into from Dec 22, 2022
Merged

Conversation

onsails
Copy link
Contributor

@onsails onsails commented Dec 16, 2022

Motivation

Nix is widely used in both rust and blockchain development as it enables reproducible builds which is crucial for dapps security and stability. This PR enables direnv setup for ethers-rs – it's a developer-friendly nix flakes wrapper. If accepted, this feature makes ethers-rs more accessible by contributions who rely on nix in their development cycle.
In a separate commit there is a git ignore of .nlsp-settings which is a directory for project-local neovim lsp settings.

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog
  • Breaking changes

@onsails onsails force-pushed the devenv branch 3 times, most recently from ea7bab6 to a12737b Compare December 16, 2022 12:47
Copy link
Owner

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

uh i don't know how to review this, @shazow can you maybe take a look?

@shazow
Copy link

shazow commented Dec 18, 2022

I haven't used direnv yet (just straight up nix) but I should try it! Will give it a try soon. Looks fairly straightforward.

@onsails
Copy link
Contributor Author

onsails commented Dec 19, 2022

I can rework this on plain nix flakes which can also easily be integrated with direnv via echo use_flake >> .envrc. Devenv is just a dev-friendly wrapper around nix flakes and direnv.

@shazow
Copy link

shazow commented Dec 19, 2022

@onsails One of the nice things about having a flake is that automatically lets you use it as a dependency in another flake, such as for packaging foundry. I assume just having the direnv settings wouldn't be enough for that?

@onsails
Copy link
Contributor Author

onsails commented Dec 20, 2022

Please see updated diff. Two birds one stone via.

Copy link

@shazow shazow left a comment

Choose a reason for hiding this comment

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

A few optional nits, but generally looks great to me. Appreciate that it works with plain nix develop as well as direnv! :)

Confirmed everything works and builds with:

$ nix develop
pre-commit-hooks.nix: updating /home/shazow/local/src/github.com/gakonst/ethers-rs repo
pre-commit installed at .git/hooks/pre-commit
(devenv)  $ cargo build
...
Finished dev [unoptimized + debuginfo] target(s) in 3m 06s

In the future might want to also add a packages output for using the flake as a dependency inside foundry, but this is great for now. Definitely makes my workflow easier.

@gakonst what do you think?

.gitignore Show resolved Hide resolved
@@ -2,3 +2,7 @@
.vscode
/.envrc
.idea
.nlsp-settings
Copy link

Choose a reason for hiding this comment

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

More up to @gakonst, but personally I just do /.* on my .gitignores and force-add whatever needs to be there (like .gitignore 😅)

Copy link
Owner

Choose a reason for hiding this comment

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

Fine with me.as is!

flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated
Comment on lines 48 to 50
# nightly fmt is required here:
# https://github.com/gakonst/ethers-rs/blob/master/.github/workflows/ci.yml#L123
# while devenv doesn't yet support customizing it:
# https://github.com/cachix/devenv/issues/211
Copy link

Choose a reason for hiding this comment

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

Thank you for adding these comments, really useful!

@onsails
Copy link
Contributor Author

onsails commented Dec 20, 2022

Also added .gitattributes to hide Cargo.lock and flake.lock diffs

@onsails
Copy link
Contributor Author

onsails commented Dec 22, 2022

another force-push, enabled nightly rutstfmt and clippy pre-commit hooks via cachix/devenv#228 (have to wait until it's merged)

@onsails
Copy link
Contributor Author

onsails commented Dec 22, 2022

Now it's merged and both rustfmt and clippy commit hooks work with nightly toolchain!

Copy link

@shazow shazow left a comment

Choose a reason for hiding this comment

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

Nice, looking good.

Copy link
Owner

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

Defer to you guys on this, merging and hopefully addresses all your issues! Thanks for the patience.

@gakonst gakonst merged commit 8673704 into gakonst:master Dec 22, 2022
@mattsse mattsse mentioned this pull request Dec 23, 2022
4 tasks
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.

None yet

3 participants