Add option to direnv shell.nix

Looking online I have come up with the following:

{
  description = "A Nix-flake-based Java development environment";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/release-24.11";
  };

  outputs = { self, nixpkgs }:
    let
      supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
      forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
        pkgs = import nixpkgs {
          inherit system;
        };
      });
    in
    {
      devShells = forEachSupportedSystem ({ pkgs }: {
        default = pkgs.mkShell {
          packages = with pkgs; [
            temurin-bin-17
            temurin-bin
            temurin-bin-23
            maven
            gradle
            gradle-completion
          ] ++ (
            if builtins.pathExists ./.devtools then [ pkgs.visualvm ]
            else [ pkgs.jmeter ]
          );
        };
      });
    };
}

Clearly the significant bit is this extra list of packages:

          ] ++ (
            if builtins.pathExists ./.devtools then [ pkgs.visualvm ]
            else [ pkgs.jmeter ]
          );

My intent is to have tools like visualvm / jmeter installed when the user does touch .devtools but even though the file exists when I under the folder, it always seems to pick the else clause (installing jmeter).

Can anyone help with this approach (or suggest an alternative)?