Error: path not valid in WSL nixos

Hello fellow nix people. I am digging into nix and nixos distro as a newcomer and it is pretty painful, but I am sure it’s worth it. I am using the latest version of NixOS-WSL (Valiant Vicuna 2411.6.0) from:

https://github.com/nix-community/NixOS-WSL/releases/tag/2411.6.0

I installed it on Windows 11 by just double-clicking on it. Worked like a charm and I am actively trying things out and learning. I found an open issue on the repo but there is no solution so far:

[error: path '/nix/store/l2sfdsab1fh107f5r8za7pnv9a2xxnlg-nixos-wsl' is not valid · Issue #595 · nix-community/NixOS-WSL · GitHub]

The expected output of the command nix-env -qaP or for example nix-env -qa 'vim' should give a collection of available packages in the current channels.

The output I get is the following:

evaluation warning: The package set `androidndkPkgs_23b` has been renamed to `androidndkPkgs_23`.
evaluation warning: cudaPackages.cudaFlags is deprecated, use cudaPackages.flags instead
evaluation warning: cudaPackages.cudaVersion is deprecated, use cudaPackages.cudaMajorMinorVersion instead
evaluation warning: CUDA versions older than 12.0 will be removed in Nixpkgs 25.05; see the 24.11 release notes for more information
evaluation warning: cudaPackages.cudaFlags is deprecated, use cudaPackages.flags instead
evaluation warning: cudaPackages.cudaVersion is deprecated, use cudaPackages.cudaMajorMinorVersion instead
evaluation warning: CUDA versions older than 12.0 will be removed in Nixpkgs 25.05; see the 24.11 release notes for more information
evaluation warning: CUDA versions older than 12.0 will be removed in Nixpkgs 25.05; see the 24.11 release notes for more information
evaluation warning: CUDA versions older than 12.0 will be removed in Nixpkgs 25.05; see the 24.11 release notes for more information
evaluation warning: CUDA versions older than 12.0 will be removed in Nixpkgs 25.05; see the 24.11 release notes for more information
evaluation warning: CUDA versions older than 12.0 will be removed in Nixpkgs 25.05; see the 24.11 release notes for more information
evaluation warning: CUDA versions older than 12.0 will be removed in Nixpkgs 25.05; see the 24.11 release notes for more information
evaluation warning: CUDA versions older than 12.0 will be removed in Nixpkgs 25.05; see the 24.11 release notes for more information
evaluation warning: CUDA versions older than 12.0 will be removed in Nixpkgs 25.05; see the 24.11 release notes for more information
error:
       … while evaluating the attribute 'nixos-wsl'

       … while calling the 'import' builtin

       … while evaluating the file '/nix/store/jvi7knli55bkmpjzv6dfa2s75w8nx0bj-nixos-wsl/nixos-wsl/default.nix':

       … while evaluating the attribute 'defaultNix'
         at /nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source/default.nix:278:3:
          277|
          278|   defaultNix =
             |   ^
          279|     builtins.removeAttrs result [ "__functor" ]

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: path '/nix/store/flzrms4bhx1h5489jl3jwbi6l2q0fyym-nixos-wsl' is not valid

Some of my outputs in the hope it helps someone helping me:

nix --version
nix (Nix) 2.28.4
sudo nix-channel --list
nixos https://nixos.org/channels/nixos-unstable
nixos-wsl https://github.com/nix-community/NixOS-WSL/archive/refs/heads/main.tar.gz
cat /etc/nixos/configuration.nix
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).

# NixOS-WSL specific options are documented on the NixOS-WSL repository:
# https://github.com/nix-community/NixOS-WSL

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

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

  wsl.enable = true;
  wsl.defaultUser = "nixos";

  # 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.11"; # Did you read the comment?

Any help appreciated.

When’s the last time you ran sudo nix-channel --update?

Hi there. Thanks for asking. About 5 minutes before I posted the error. It doesn’t do anything to help, unfortunately.

If this can contribute to a possible solution, here is the outcome of nix-env -qaP --show-trace. Maybe the trace can give a hint. TIA.

error:
       … while evaluating the attribute 'nixos-wsl'

       … while calling the 'import' builtin

       … while evaluating the file '/nix/store/h3wada9l7lqiki0i780i63hr1alhx112-nixos-wsl/nixos-wsl/default.nix':

       … while evaluating the attribute 'defaultNix'
         at /nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source/default.nix:278:3:
          277|
          278|   defaultNix =
             |   ^
          279|     builtins.removeAttrs result [ "__functor" ]

       … in the left operand of the update (//) operator
         at /nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source/default.nix:280:5:
          279|     builtins.removeAttrs result [ "__functor" ]
          280|     // (
             |     ^
          281|       if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else { }

       … while calling the 'removeAttrs' builtin
         at /nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source/default.nix:279:5:
          278|   defaultNix =
          279|     builtins.removeAttrs result [ "__functor" ]
             |     ^
          280|     // (

       … from call site
         at /nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source/default.nix:270:7:
          269|     else if lockFile.version >= 5 && lockFile.version <= 7 then
          270|       allNodes.${lockFile.root}
             |       ^
          271|     else

       … while calling anonymous lambda
         at /nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source/default.nix:200:10:
          199|   allNodes = builtins.mapAttrs (
          200|     key: node:
             |          ^
          201|     let

       … in the condition of the assert statement
         at /nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source/default.nix:258:7:
          257|     if node.flake or true then
          258|       assert builtins.isFunction flake.outputs;
             |       ^
          259|       result

       … while calling the 'isFunction' builtin
         at /nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source/default.nix:258:14:
          257|     if node.flake or true then
          258|       assert builtins.isFunction flake.outputs;
             |              ^
          259|       result

       … while calling the 'import' builtin
         at /nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source/default.nix:212:15:
          211|
          212|       flake = import (outPath + "/flake.nix");
             |               ^
          213|

       … while realising the context of path '/nix/store/i3clzjhz549abhkzbiich3gqna0rp7sg-nixos-wsl/flake.nix'

       error: path '/nix/store/i3clzjhz549abhkzbiich3gqna0rp7sg-nixos-wsl' is not valid