NixOS-WSL glxinfo not recognizing my NVIDIA card

Hello, I am a newbie to NixOS and tried to follow https://nixos-and-flakes.thiscute.world/ for some time. After that, I write a configuration.nix for my laptop like this:

{ config, lib, pkgs, wayland, ... }:

{
  #imports = [
  #  # include NixOS-WSL modules
  #  <nixos-wsl/modules>
  #];

  wsl.enable = true;
  wsl.defaultUser = "nixos";
  wsl.useWindowsDriver = true;
  nix.settings.experimental-features = [ "nix-command" "flakes" ];
  environment.systemPackages = with pkgs; [
    git
    neovim
    wget
    openssl
  ];

  boot.loader.systemd-boot.configurationLimit = 10;
  nix.gc = {
    automatic = true;
    dates = "weekly";
    options = "--delete-older-than 1w";
  };
  nix.settings.auto-optimise-store = true;

  nix.settings.trusted-public-keys = [
    "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
    "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
  ];
  nix.settings.substituters = [
    "https://cache.nixos.org"
    "https://nixpkgs-wayland.cachix.org"
  ];

  nixpkgs.config.allowUnfree = true;
  hardware.graphics = {
    enable = true;
    enable32Bit = true;
    #driSupport = true;
    #setLdLibraryPath = true;
    extraPackages = with pkgs; [
      mesa.drivers
      libvdpau-va-gl
      egl-wayland
      libglvnd
      (libedit.overrideAttrs (attrs: {postInstall = (attrs.postInstall or "") + ''ln -s $out/lib/libedit.so $out/lib/libedit.sp.2'';}))
    ];
  };
  #environment.etc."egl/egl_external_platform.d/10_nvidia_wayland.json".text = ''
  #{
  #  "file_format_version": "1.0.0",
  #  "ICD": {
  #    "library_path": "${pkgs.egl-wayland}/lib/libnvidia-egl-wayland.so"
  #  }
  #}
  #'';
  #boot.kernelParams = [ "nvidia-drm.modeset=1" ];

  environment.sessionVariables = {
    #CUDA_PATH = "${pkgs.cudatoolkit}";
    EXTRA_LDFLAGS = "-L/lib -L${pkgs.linuxPackages.nvidia_x11}/lib";
    EXTRA_CCFLAGS = "-I/usr/include";
    LD_LIBRARY_PATH = [
      "/usr/lib/wsl/lib"
      "${pkgs.linuxPackages.nvidia_x11}/lib"
      "${pkgs.ncurses5}/lib"
      "/run/opengl-driver/lib"
    ];
    MESA_D3D12_DEFAULT_ADAPTER_NAME = "Nvidia";
  };
  programs.nix-ld.enable = true;
  environment.variables = {
    NIX_LD_LIBRARY_PATH = lib.mkForce (lib.makeLibraryPath [ pkgs.stdenv.cc.cc ]);
    NIX_LD = lib.mkForce "${pkgs.glibc}/lib/ld-linux-x86-64.so.2";
  };
  boot.initrd.kernelModules = [ "nvidia" ];
  boot.blacklistedKernelModules = [ "nouveau" ];
  services.xserver.videoDrivers = [ "nvidia" ];
  #hardware.nvidia-container-toolkit = {
  #  enable = true;
  #  mount-nvidia-executables = false;
  #};
  hardware.nvidia = {
    modesetting.enable = true;
    powerManagement.enable = false;
    powerManagement.finegrained = false;
    open = true;
    nvidiaSettings = true;
    package = config.boot.kernelPackages.nvidiaPackages.beta;
  };

  #security.pki.certificateFiles = [
  #  ./SteamTools.Certificate.cer
  #];
  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It's perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "24.05"; # Did you read the comment?
}

and include it in a flake.nix file. When I use glxinfo -B inside nix-shell -p glxinfo, it prints

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa (0xffffffff)
    Device: llvmpipe (LLVM 19.1.5, 256 bits) (0xffffffff)
    Version: 24.3.3
    Accelerated: no
    Video memory: 15797MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 4.5
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 31 MB, largest block: 31 MB
    VBO free aux. memory - total: 14989 MB, largest block: 14989 MB
    Texture free memory - total: 31 MB, largest block: 31 MB
    Texture free aux. memory - total: 14989 MB, largest block: 14989 MB
    Renderbuffer free memory - total: 31 MB, largest block: 31 MB
    Renderbuffer free aux. memory - total: 14989 MB, largest block: 14989 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 4294373003 MB
    Total available memory: 4294388801 MB
    Currently available dedicated video memory: 31 MB
OpenGL vendor string: Mesa
OpenGL renderer string: llvmpipe (LLVM 19.1.5, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 24.3.3
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.5 (Compatibility Profile) Mesa 24.3.3
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 24.3.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

while vulkaninfo --summary and nvidia-smi (passed with wsl and tweaked using the nix-ld flags) both recognized a NVIDIA card. But lshw and lspci didn’t show any gpu related info either.

PS. This is actually a Y problem from my X problem on how to make zed work on NixOS-WSL, but when I read through the solutions online, it seems that my config prints a lot of different information from other people, so I decide to correct my settings.

My flake.nix and home.nix are pretty simple and contains nothing personal. I have a lot of trouble to make nvidia-smi work (with a ld trick) and make vulkaninfo work (it used to prints only about llvmpipe device and i don’t know why it works now).

I have no previous experience with NVIDIA either. Is there a correct way to install nvidia things in nixos-wsl, like nvidia-smi? Please tell me.