{ # XXX: Change project description description = "Rust project"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11"; fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, fenix, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages."${system}"; # XXX: Change target platform rust-target = "x86_64-unknown-linux-gnu"; rust-toolchain = with fenix.packages."${system}"; let rust-toolchain-spec = { # XXX: Change compiler version # see `toolchainOf` https://github.com/nix-community/fenix # for supported options channel = "nightly"; sha256 = "sha256-E4uFH1xyP6u3KhsYf3gnuqWyee61O9uoLLvBEIF1+ko="; }; # Toolchain for the builder host-toolchain = toolchainOf rust-toolchain-spec; # Toolchain for the platform where the binary will run # target-toolchain = targets."${rust-target}".toolchainOf rust-toolchain-spec; in combine [ # Build tools are taken from the host host-toolchain.rustc host-toolchain.cargo host-toolchain.clippy host-toolchain.rust-docs # Standard library is taken from the target host-toolchain.rust-std host-toolchain.rust-src ]; in { devShells.default = pkgs.mkShell { # XXX: Change to project name name = "rust-project"; # Build tools nativeBuildInputs = with pkgs; [ rust-toolchain rust-analyzer rustfmt ]; RUST_BACKTRACE = 1; # CARGO_BUILD_TARGET = rust-target; }; devShell = self.devShells."${system}".default; }); }