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

chore: add nix flake for dev shell #6412

Merged
merged 3 commits into from
Dec 10, 2023
Merged

Conversation

beeb
Copy link
Contributor

@beeb beeb commented Nov 23, 2023

This PR adds a nix flake definition for a dev shell that provides the necessary components to building and testing foundry.

Motivation

In order to compile and test successfully, the workspace requires Rust nightly, solc and libusb. These dependencies must be installed by users and could be provided system wide. However, it's a good idea to provide nix users with a pre-configured devShell that includes all these dependencies.

Solution

A nix flake is a deterministic definition file that configures the required nix packages that must be present in the PATH when developing a project.

The shell can be activated with the nix develop command and provides the rust toolchain on nightly with clippy and rustfmt, the solidity compiler at v0.8.20 and libusb1.

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

unfortunately, I haven't gotten into nix yet...
so I'm not really familiar with these settings, but I think these don't require too much maintenance so I'm okay with including this.

wdyt @DaniPopes @onbjerg @Evalir ?

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

I also don't really know nix, so i'm not too qualified to review this—but I think what we want is something that ideally is not opinionated and therefore won't lead us to get many patches for this. I'm ok with including this if it's like so

@beeb
Copy link
Contributor Author

beeb commented Nov 23, 2023

The only maintenance would be to update the lock file when a new nightly for the rust compiler would be desirable or when a different version of solc would be required (in this case also the flake would require an update). This is done with nix flake update .

@beeb
Copy link
Contributor Author

beeb commented Nov 23, 2023

Later I can check on my Mac that everything is also included for mac development

@beeb
Copy link
Contributor Author

beeb commented Nov 23, 2023

In case absolutely no maintenance is required, I think publishing the flake.nix without the lock file (and adding it to .gitignore) could also be a viable solution. But then it's not 100% reproducible, someone might use a different nightly than someone else. At the moment since you don't include a rust-toolchain.toml I think anyway there is no version of the rust compiler that is enforced.

@mattsse
Copy link
Member

mattsse commented Nov 23, 2023

nix flake update .

I think that we can manage

sgtm

any concerns @onbjerg ?

@beeb
Copy link
Contributor Author

beeb commented Nov 23, 2023

Wait to merge, I have a couple of things to add for macOS

EDIT: all good now

@Evalir
Copy link
Member

Evalir commented Nov 23, 2023

let's wait for breg's approval before merging

@sambacha
Copy link
Contributor

sambacha commented Dec 5, 2023

I will literally stop shitposting if this is merged 

Inshallah @gakonst sees this pls ser make it a happy merry christmas

@cawfree
Copy link

cawfree commented Dec 5, 2023

add a what to the what now

@Evalir
Copy link
Member

Evalir commented Dec 5, 2023

@onbjerg sir

@mattsse mattsse merged commit 22f3d70 into foundry-rs:master Dec 10, 2023
19 checks passed
@beeb beeb deleted the chore/nix-flake branch December 10, 2023 21:09
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.

5 participants