Rust project template with Nix (Flakes) and VSCode support
See the codeA template Rust project with fully functional and no-frills Nix support, as well as builtin VSCode configuration to get IDE experience without any manual setup (just install direnv, open in VSCode and accept the suggestions). It uses crane, via rust-flake.
[!NOTE] If you are looking for the original template based on this blog post's use of
crate2nix, browse from this tag. The evolution of this template can be gleaned from releases.
You can use omnix1 to initialize this template:
nix run nixpkgs#omnix -- init github:srid/rust-nix-template -o ~/my-rust-project
This repo uses Flakes from the get-go.
# Dev shell
nix develop
# or run via cargo
nix develop -c cargo run
# build
nix build
We also provide a justfile for Makefile'esque commands to be run inside of the devShell.
nix flake update to update all flake inputs.nix --accept-flake-config run github:juspay/omnix ci to build all outputs.pre-commit run -a manually to run the hooks (e.g.: to autoformat the project tree using rustfmt, nixpkgs-fmt, etc.).If initializing manually, make sure to:
name in Cargo.toml.cargo generate-lockfile in the nix shelldNix
75.1%
Rust
10.2%
Just
6.0%
Haskell
5.1%
Shell
3.6%
Rust project template with Nix (Flakes) and VSCode support
See the codeA template Rust project with fully functional and no-frills Nix support, as well as builtin VSCode configuration to get IDE experience without any manual setup (just install direnv, open in VSCode and accept the suggestions). It uses crane, via rust-flake.
[!NOTE] If you are looking for the original template based on this blog post's use of
crate2nix, browse from this tag. The evolution of this template can be gleaned from releases.
You can use omnix1 to initialize this template:
nix run nixpkgs#omnix -- init github:srid/rust-nix-template -o ~/my-rust-project
This repo uses Flakes from the get-go.
# Dev shell
nix develop
# or run via cargo
nix develop -c cargo run
# build
nix build
We also provide a justfile for Makefile'esque commands to be run inside of the devShell.
nix flake update to update all flake inputs.nix --accept-flake-config run github:juspay/omnix ci to build all outputs.pre-commit run -a manually to run the hooks (e.g.: to autoformat the project tree using rustfmt, nixpkgs-fmt, etc.).If initializing manually, make sure to:
name in Cargo.toml.cargo generate-lockfile in the nix shelldNix
75.1%
Rust
10.2%
Just
6.0%
Haskell
5.1%
Shell
3.6%