Setup develop environment - faas-rs/faasd-in-rust GitHub Wiki

Thanks to the nix, we can easily develop the project in a reproducible environment. The following steps will guide you through the process.

nix environment

shell interactions

There are several integrated nix commands that can help you develop the project.

  • nix develop Enter the default development shell. Usually already activated when you open the repo dir if you configured nix env correctly.
  • nix build Build the project, the result will be at result/bin/faas-rs
  • nix flake check Do 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.

Rust Environment with crane

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)
          ];
        };