diff --git a/README.md b/README.md index de95aca185e..47011536cf2 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ $ cargo --version cargo 1.49.0 (d00d64df9 2020-12-05) ``` +### Example: NixOS Configuration + Here's an example of using it in nixos configuration. ```nix { @@ -77,6 +79,49 @@ Here's an example of using it in nixos configuration. } ``` +### Example: Using `devShell` and `nix develop` + +Running `nix develop` will create a shell with the default nightly Rust toolchain installed: + +```nix +{ + description = "A devShell example"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + in + { + devShell = pkgs.mkShell { + buildInputs = [ + pkgs.openssl + pkgs.pkgconfig + pkgs.exa + pkgs.fd + pkgs.rust-bin.nightly.latest.default + ]; + + shellHook = '' + alias ls=exa + alias find=fd + ''; + }; + } + ); +} + +``` + ## Attributes provided by the overlay ```nix