{
  description = "bevy flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    crane.url = "github:ipetkov/crane";
    flake-utils.url = "github:numtide/flake-utils";
    rust-overlay = {
      url = "github:oxalica/rust-overlay";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    nixpkgs,
    rust-overlay,
    flake-utils,
    crane,
    ...
    }:
    flake-utils.lib.eachDefaultSystem (
      system: let
        overlays = [(import rust-overlay)];
        pkgs = import nixpkgs {
          inherit overlays system;
        };
        # here you can have two pkgs, but you need to duplicate everything
        # pkgsCross = import nixpkgs {
        #   inherit overlays;
        #   localSystem = system;
        #   crossSystem = {
        #     config = "x86_64-w64-mingw32";
        #     libc = "msvcrt";
        #   };
        # };
        inherit (pkgs) lib;
        rust-toolchain = pkgs.rust-bin.stable.latest;
        craneLib = (crane.mkLib pkgs).overrideToolchain (
          p:
          p.rust-bin.stable.latest.default.override {
            targets = [ "x86_64-pc-windows-gnu" "x86_64-unknown-linux-gnu" ];
          }
        );
        commonArgs = {
          buildInputs = [
            # common dependencies
          ];
          src = craneLib.cleanCargoSource ./.;
          strictDeps = true;
        };
        linux = craneLib.buildPackage (commonArgs //{
          buildInputs = [
            # linux
          ];
        });
        rust-flags = "-L ${pkgs.lib.makeLibraryPath [ pkgs.pkgsCross.mingwW64.windows.pthreads ]}";
        windows = craneLib.buildPackage (commonArgs //{
          buildInputs = with pkgs.pkgsCross.mingwW64; [
            # windows
          ];
          CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
          CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER = "${pkgs.lib.getExe pkgs.pkgsCross.mingwW64.stdenv.cc}";
          RUSTFLAGS = rust-flags;
          doCheck = false;
        });
        windows-shell = craneLib.devShell {
          packages = [
            pkgs.pkgsCross.mingwW64.buildPackages.gcc
          ];
          CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
          RUSTFLAGS = rust-flags;
        };
      in {
        devShells = {
          windows = windows-shell;
          default = craneLib.devShell {
            packages = with pkgs; [
              # Rust dependencies
              pkg-config
              bacon

              wayland
              # for Linux
              # Audio (Linux only)
              alsa-lib
              # Cross Platform 3D Graphics API
              vulkan-loader
              # For debugging around vulkan
              pkgs.vulkan-tools
              # Other dependencies
              libudev-zero
              libx11
              libxcursor
              libxi
              libxrandr
              libxkbcommon
            ] ++ lib.optionals (lib.strings.hasInfix "linux" system) [
                # for Linux
                # Audio (Linux only)
                alsa-lib
                # Cross Platform 3D Graphics API
                vulkan-loader
                # For debugging around vulkan
                vulkan-tools
                # Other dependencies
                libudev-zero
                libx11
                libxcursor
                libxi
                libxrandr
                libxkbcommon
              ];

            # i think there is a way for libCrane to complete this but i dont remember
            RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
            LD_LIBRARY_PATH = lib.makeLibraryPath [
              pkgs.vulkan-loader
              pkgs.libx11
              pkgs.libxi
              pkgs.libxcursor
              pkgs.libxkbcommon
            ];

            shellHook = ''
              export CARGO_CLIPPY_FLAGS='-- -W clippy::pedantic -W clippy::nursery -W clippy::unwrap_used'
            '';
          };
        };
        packages = {
          default = linux; # nix build
          windows = windows; # nix build .#windows
        };
      });
}