-
Notifications
You must be signed in to change notification settings - Fork 9
Setup develop environment
Thanks to the nix, we can easily develop the project in a reproducible environment. The following steps will guide you through the process.
-
nix installation
-
home-manager
Manage nix features (flakes) and direnv (Optional)
https://nix-community.github.io/home-manager/index.xhtml#sec-install-standalone
-
direnv
For development environment activation
https://github.com/nix-community/nix-direnv#via-home-manager
-
VSCode extensions
Automatically environment activation. We have recommand extensions:
- pinage404.nix-extension-pack: provide direnv and essentials for activating nix dev env
- rust-lang.rust-analyzer: Rust language support
There are several integrated nix commands that can help you develop the project.
-
nix developEnter the default development shell. Usually already activated when you open the repo dir if you configured nix env correctly. -
nix buildBuild the project, the result will be atresult/bin/faas-rs -
nix flake checkDo the CI checks, including formatting, linting...
Besides, you can also use the cargo command to interact with the project in the shell. Nix will automatically manage the toolchain and library dependencies for you.
Note
The project uses cargo-hakari to optimize the build time. If you don't know what it is, after new dependencies are added, you should run cargo hakari generate to update the dependencies. Details below.
Reference: https://crane.dev/examples/quick-start-workspace.html
If you add an extra crate into crates dir, make sure add it in to Cargo.toml under the my-workspace-hack crate, and add the dir path to flake.nix:
fileSetForCrate = crate: lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
(craneLib.fileset.commonCargoSources ./crates/app)
(craneLib.fileset.commonCargoSources ./crates/service)
(craneLib.fileset.commonCargoSources ./crates/provider)
(craneLib.fileset.commonCargoSources ./crates/cni)
(craneLib.fileset.commonCargoSources ./crates/my-workspace-hack)
(craneLib.fileset.commonCargoSources crate)
];
};