Why referencing directly a flake input causes an error?

I have this flake:

{
  inputs = {
    copper.url = "github:zoedsoupe/copper";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
  };

  outputs = { self, nixpkgs, ... }@inputs:
    let
      system = "x86_64-linux";

      pkgs = import nixpkgs {
        inherit system;
        overlays = [ inputs.copper.overlays."${system}".default ];
        config.allowUnfree = true;
      };
    in rec {
      devShells."${system}".default = pkgs.mkShell {
        name = "sqlite_project";
        buildInputs = with pkgs; [
          wget gcc python310 sqlite copper
        ];
      };
    };
}

However if I do something like this:

{
  inputs = {
    copper.url = "github:zoedsoupe/copper";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
  };

  outputs = { self, nixpkgs, copper }:
    let
      system = "x86_64-linux";

      pkgs = import nixpkgs {
        inherit system;
        overlays = [ copper.overlays."${system}".default ];
        config.allowUnfree = true;
      };
    in rec {
      devShells."${system}".default = pkgs.mkShell {
        name = "sqlite_project";
        buildInputs = with pkgs; [
          wget gcc python310 sqlite copper
        ];
      };
    };
}

I receive an error: Dependency is not of a valid type nix shell

What does that means?

with is evil and you shouldn’t use it.

The copper from pkgs will not be pulled into scope as it then would shadow an explicitely declared binding. with will never do that. So the copper in the buildInputs is the flake input.

NB: You should not use buildInputs and ativeBuildInputs in mkShell directly, unless you follow the callPackage idiom and need a shell thats capable of crosscompiling.