File tree Expand file tree Collapse file tree 5 files changed +199
-0
lines changed
Expand file tree Collapse file tree 5 files changed +199
-0
lines changed Original file line number Diff line number Diff line change 1+ # Add environment variables here to be available in development session.
2+ # Example: export SECRET_TOKEN=01234
Original file line number Diff line number Diff line change @@ -118,3 +118,92 @@ fcidr 10.0.0.0/8 + 127.0.0.0/16 | fcidr - 10.64.0.0/16 | fcidr !
118118127.128.0.0/9
119119128.0.0.0/1
120120```
121+
122+ ### Development
123+
124+ #### Prerequisites
125+
126+ - [ nix] ( https://nixos.org/download.html )
127+ - [ nix flakes] ( https://nixos.wiki/wiki/Flakes#Enable_flakes )
128+
129+ #### How-to
130+
131+ Create the development shell environment. Necessary to run all other commands.
132+
133+ ``` shell
134+ nix develop
135+ ```
136+
137+ Build with cargo.
138+
139+ ``` shell
140+ just build
141+ ```
142+
143+ Check the code with cargo's built-in fast static analysis.
144+
145+ ``` shell
146+ just check
147+ ```
148+
149+ Remove build files.
150+
151+ ``` shell
152+ just clean
153+ ```
154+
155+ Format the code.
156+
157+ ``` shell
158+ just format
159+ ```
160+
161+ Check the code with clippy for better static analysis.
162+
163+ ``` shell
164+ just lint
165+ ```
166+
167+ Run the application.
168+
169+ ``` shell
170+ just run
171+ ```
172+
173+ Run tests with cargo's built-in test runner.
174+
175+ ``` shell
176+ just test
177+ ```
178+
179+ Watch for code changes and rebuild.
180+
181+ ``` shell
182+ just watch
183+ ```
184+
185+ All ` just ` commands can accept additional command line arguments after a ` -- ` .
186+
187+ For example: run the application with a flag to report the version.
188+
189+ ``` shell
190+ just run -- --version
191+ ```
192+
193+ ##### Tips and Recommendations
194+
195+ ###### Open IDE from Development Shell
196+
197+ To get linking to rust binaries in your IDE, you should open the development shell from your terminal and then open your IDE
198+ from that shell session. This will carry over the development shell's environment into your IDE.
199+
200+ For example if you work with VSCode.
201+
202+ ``` shell
203+ cd path/to/this/project
204+ nix develop
205+ code .
206+ ```
207+
208+ By doing this, you can install the rust-analyzer VSCode extension and it will work properly since it will be able to point to
209+ the correct rust binaries and libraries. You will also have access in VSCode to any packages installed by the nix flake.
Original file line number Diff line number Diff line change 1+ {
2+ inputs = {
3+ flake-utils . url = "github:numtide/flake-utils" ;
4+ } ;
5+
6+ outputs = { self , nixpkgs , flake-utils } :
7+ flake-utils . lib . eachDefaultSystem ( system : let
8+ pkgs = nixpkgs . legacyPackages . ${ system } ;
9+ in {
10+ devShell = pkgs . mkShell {
11+ buildInputs = [
12+ pkgs . cargo-watch
13+ pkgs . iconv
14+ pkgs . just
15+ pkgs . nerdfonts
16+ pkgs . rustup
17+ pkgs . starship
18+ ] ;
19+ shellHook = ''
20+ source .env
21+ rustup default stable
22+ eval "$(starship init bash)"
23+ '' ;
24+ } ;
25+ } ) ;
26+ }
Original file line number Diff line number Diff line change 1+ build * ARGS :
2+ cargo build {{ ARGS}}
3+
4+ check * ARGS :
5+ cargo check {{ ARGS}}
6+
7+ clean *ARGS:
8+ cargo clean {{ ARGS}}
9+
10+ format * ARGS :
11+ cargo format {{ ARGS}}
12+
13+ lint * ARGS :
14+ cargo lint {{ ARGS}}
15+
16+ run * ARGS :
17+ cargo run {{ ARGS}}
18+
19+ test * ARGS :
20+ cargo test {{ ARGS}}
21+
22+ watch * ARGS :
23+ cargo watch {{ ARGS}}
You can’t perform that action at this time.
0 commit comments