flake.nix
1 { 2 description = "A Nix-flake-based Rust development environment"; 3 4 inputs = { 5 nixpkgs.url = "github:NixOS/nixpkgs/release-22.11"; 6 flake-utils.url = "github:numtide/flake-utils"; 7 rust-overlay.url = "github:oxalica/rust-overlay"; 8 }; 9 10 outputs = 11 { self 12 , nixpkgs 13 , flake-utils 14 , rust-overlay 15 }: 16 17 flake-utils.lib.eachDefaultSystem (system: 18 let 19 overlays = [ 20 (import rust-overlay) 21 (self: super: { 22 rustToolchain = 23 let 24 rust = super.rust-bin; 25 in 26 if builtins.pathExists ./rust-toolchain.toml then 27 rust.fromRustupToolchainFile ./rust-toolchain.toml 28 else if builtins.pathExists ./rust-toolchain then 29 rust.fromRustupToolchainFile ./rust-toolchain 30 else 31 rust.stable.latest.default; 32 }) 33 ]; 34 35 pkgs = import nixpkgs { inherit system overlays; }; 36 in 37 { 38 devShells.default = pkgs.mkShell { 39 packages = with pkgs; [ 40 rustToolchain 41 openssl 42 pkg-config 43 cargo-deny 44 cargo-edit 45 cargo-watch 46 rust-analyzer 47 ]; 48 49 shellHook = '' 50 ${pkgs.rustToolchain}/bin/cargo --version 51 ''; 52 }; 53 }); 54 }