Add cargo-watch, demonstrating addition of build tools

This commit is contained in:
Sridhar Ratnakumar 2021-04-11 21:30:21 -04:00
parent c1d42ef654
commit 2f00d8d376
2 changed files with 12 additions and 5 deletions

View file

@ -5,13 +5,13 @@ See [Nix-ifying Rust projects](https://notes.srid.ca/rust-nix) for details.
## Adapting this template ## Adapting this template
- Change `name` in Cargo.toml and flake.nix. Also change `description` in flake.nix. - Change `name` in Cargo.toml and flake.nix. Also change `description` in flake.nix.
- There are two CI workflows, and one of them uses Nix which is slower than the other based on rustup. Pick one or the other depending on your trade-offs. - There are two CI workflows, and one of them uses Nix which is slower (unless you configure a cache) than the other that is based on rustup. Pick one or the other depending on your trade-offs.
## Development (Flakes) ## Development (Flakes)
This repo uses [Flakes](https://nixos.wiki/wiki/Flakes) from the get-go, but compat is provided for traditional nix-shell/nix-build as well (see the section below). This repo uses [Flakes](https://nixos.wiki/wiki/Flakes) from the get-go, but compat is provided for traditional nix-shell/nix-build as well (see the section below).
``` ```bash
# Dev shell # Dev shell
nix develop nix develop
@ -27,7 +27,7 @@ nix build
## Development (Legacy Nix) ## Development (Legacy Nix)
``` ```bash
# Dev shell # Dev shell
nix-shell nix-shell

View file

@ -63,7 +63,7 @@
# Configuration for the non-Rust dependencies # Configuration for the non-Rust dependencies
buildInputs = with pkgs; [ openssl.dev ]; buildInputs = with pkgs; [ openssl.dev ];
nativeBuildInputs = with pkgs; [ rustc cargo pkgconfig nixpkgs-fmt ]; nativeBuildInputs = with pkgs; [ rustc cargo pkgconfig ];
in in
rec { rec {
packages.${name} = project.rootCrate.build; packages.${name} = project.rootCrate.build;
@ -81,7 +81,14 @@
# `nix develop` # `nix develop`
devShell = pkgs.mkShell devShell = pkgs.mkShell
{ {
inherit buildInputs nativeBuildInputs; inputsFrom = builtins.attrValues self.packages.${system};
buildInputs = buildInputs ++ (with pkgs;
# Tools you need for development go here.
[
nixpkgs-fmt
cargo-watch
]);
# FIXME: Is this correct? Should it use rust-overlay instead?
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}; };
} }