-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add dev shell environment #1534
Conversation
Examples: # No rust toolchain is installed in my system, and I have `stellar` installed in ~/.cargo/bin/stellar
ifro@nixos:~/projects/stellar-cli/ > which cargo
cargo not found
ifro@nixos:~/projects/stellar-cli/ > stellar --version
stellar 21.2.0 (v20.0.0-248-g96e819c949089a6744621164bb406fc411de676e-dirty)
soroban-env 21.2.0 (8809852dcf8489f99407a5ceac12625ee3d14693)
soroban-env interface version 90194313216
stellar-xdr 21.2.0 (9bea881f2057e412fdbb98875841626bf77b4b88)
xdr curr (70180d5e8d9caee9e8645ed8a38c36a8cf403cd9)
ifro@nixos:~/projects/stellar-cli/ > nix develop
Using nix (Nix) 2.20.8
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
Running `target/debug/stellar keys add dev_key`
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
Running `target/debug/stellar completion --shell bash`
# Have rust toolchain in devshell, and `stellar` points to the freshly built binary
[ifro@nixos:~/projects/stellar-cli]$ which cargo
/nix/store/i223gfb0a86hxywdsqxmyy291z511056-rust-default-1.80.0/bin/cargo
[ifro@nixos:~/projects/stellar-cli]$ stellar --version
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
Running `target/debug/stellar --version`
stellar 21.3.0 (v20.0.0-257-g0e615b6c61d03ab294fd6ccab42b1b08f317a437)
soroban-env 21.2.0 (8809852dcf8489f99407a5ceac12625ee3d14693)
soroban-env interface version 90194313216
stellar-xdr 21.2.0 (9bea881f2057e412fdbb98875841626bf77b4b88)
xdr curr (70180d5e8d9caee9e8645ed8a38c36a8cf403cd9) |
Also no documentation on it at the moment, open to suggestions on where to add it (README.md or CONTRIBUTING.md) |
Documentation should be in CONTRIBUTING.md I think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if many folks deving on the cli use nixos, but sounds like you do @Ifropc. Can you remove the secret key and setup assumptions so that the flake is only the tool setup and doesn't make other assumptions? Otherwise lgtm.
I added secret key just cause I thought it'd be a good idea to easily test things locally (so shared dev secret key is fine) but I now I think it's better if i remove exporting the variable when key is not defined instead |
It's very easy for devs to create a key, it's a single command, |
Co-authored-by: Leigh McCulloch <[email protected]>
Before I open an issue perhaps asking here makes sense: why the libudev0 dependency? That means it can't be used on mac/darwin. |
What
This PR adds a devshell environment using nix
Why
Currently, in order to develop stellar-cli locally you need to install some dependencies, and sometimes you also need to modify your
.<shell>rc
file to make your environment easy to use for development.However, this makes switching between different branches/versions or switching between development/production builds more complicated.
This change adds a configuration for a development shell, which automatically does the following:
nix collect-garbage
.stellar
alias, configure development key and environment (setSTELLAR_NETWORK
andSTELLAR_ACCOUNT
variables)Developer simply needs to install nix and run
nix develop
This should work both on any Linux distro, Mac (Darwin builds are available for all packages in nixpkgs) and Windows WSL
Known limitations
nix is required to be installed in the system, with v2.20+
Currently
bash
is used as a default shell. It's possible to use other shells withnix develop -c zsh