{
  description = "A simple Rust development environment";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    utils.url = "github:numtide/flake-utils";
  };

  outputs =
    {
      self,
      nixpkgs,
      utils,
    }:
    utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs { inherit system; };
      in
      {
        devShells.default = pkgs.mkShell {

          name = "rustshell";

          buildInputs = with pkgs; [
            # Rust toolchain
            rustc
            cargo
            rustfmt
            clippy
            rust-analyzer

            # Common dependencies for Rust crates
            pkg-config
            openssl
          ];

          # Environment variables
          shellHook = ''
            export RUST_BACKTRACE=1

            # Trigger zsh if not already in it
            if [[ -z "$ZSH_VERSION" ]]; then
              exec zsh
            fi
          '';
        };
      }
    );
}
