Windows wsl2 getting started problems

At Install Nix — nix.dev documentation, wsl2 tab, the first instruction is:
curl -L https://nixos.org/nix/install | sh -s – --no-daemon

This was confusing to me because from a DOS command prompt there is no access to ‘sh’

I discovered I can just run:
wsl
and then the curl line to install.

However, once I exit, NixOS does not appear in wsl --list.
It would be nice if it was permanently installed. It seems to disappear on exit.
Oh, I can run
wsl
. /home/jbritton/.nix-profile/etc/profile.d/nix.sh

Although that is not as nice as wsl -d NixOS

nix --version
nix (Nix) 2.23.3

Next, I have the following nix script that gives errors, and I’m wondering if it is nixos-23.11 that is the problem. That value is straight from the tutorial.
I don’t know how to find other tarballs. There is no tarball folder at that location.

let
nixpkgs = fetchTarball “https://github.com/NixOS/nixpkgs/tarball/nixos-23.11”;
pkgs = import nixpkgs { config = {}; overlays = ; };
in

pkgs.mkShellNoCC {
packages = with pkgs; [
python3.12
qt5full
python312Packages.pyside2
python312Packages.pillow
];
QT_BINDINGS = “PySide2”;
DISPLAY = “:0”;
}

error:
… while calling the ‘derivationStrict’ builtin
at <nix/derivation-internal.nix>:9:12:
8|
9| strict = derivationStrict drvAttrs;
| ^
10|

   … while evaluating derivation 'nix-shell'
     whose name attribute is located at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/pkgs/stdenv/generic/make-derivation.nix:348:7

   … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/pkgs/stdenv/generic/make-derivation.nix:392:7:
      391|       depsBuildBuild              = elemAt (elemAt dependencies 0) 0;
      392|       nativeBuildInputs           = elemAt (elemAt dependencies 0) 1;
         |       ^
      393|       depsBuildTarget             = elemAt (elemAt dependencies 0) 2;

   … while calling 'getOutput'
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/lib/attrsets.nix:1045:23:
     1044|   */
     1045|   getOutput = output: pkg:
         |                       ^
     1046|     if ! pkg ? outputSpecified || ! pkg.outputSpecified

   … while evaluating a branch condition
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/lib/attrsets.nix:1046:5:
     1045|   getOutput = output: pkg:
     1046|     if ! pkg ? outputSpecified || ! pkg.outputSpecified
         |     ^
     1047|       then pkg.${output} or pkg.out or pkg

   … in the left operand of the OR (||) operator
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/lib/attrsets.nix:1046:32:
     1045|   getOutput = output: pkg:
     1046|     if ! pkg ? outputSpecified || ! pkg.outputSpecified
         |                                ^
     1047|       then pkg.${output} or pkg.out or pkg

   … in the argument of the not operator
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/lib/attrsets.nix:1046:10:
     1045|   getOutput = output: pkg:
     1046|     if ! pkg ? outputSpecified || ! pkg.outputSpecified
         |          ^
     1047|       then pkg.${output} or pkg.out or pkg

   … from call site
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/lib/attrsets.nix:1046:10:
     1045|   getOutput = output: pkg:
     1046|     if ! pkg ? outputSpecified || ! pkg.outputSpecified
         |          ^
     1047|       then pkg.${output} or pkg.out or pkg

   … while calling anonymous lambda
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/pkgs/stdenv/generic/make-derivation.nix:289:13:
      288|       (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild))
      289|       (map (drv: drv.__spliced.buildHost or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs'))
         |             ^
      290|       (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget))

   … from call site
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/pkgs/stdenv/generic/make-derivation.nix:289:18:
      288|       (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild))
      289|       (map (drv: drv.__spliced.buildHost or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs'))
         |                  ^
      290|       (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget))

   … while calling anonymous lambda
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/lib/lists.nix:165:29:
      164|   */
      165|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
         |                             ^
      166|

   … from call site
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/lib/lists.nix:165:32:
      164|   */
      165|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
         |                                ^
      166|

   … while calling anonymous lambda
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/pkgs/stdenv/generic/make-derivation.nix:261:73:
      260|   checkDependencyList = checkDependencyList' [];
      261|   checkDependencyList' = positions: name: deps: flip imap1 deps (index: dep:
         |                                                                         ^
      262|     if isDerivation dep || dep == null || builtins.isString dep || builtins.isPath dep then dep

   … while calling the 'throw' builtin
     at /nix/store/6viki0xn0rpxw1spfn1kp1ii2s19v75x-source/pkgs/stdenv/generic/make-derivation.nix:264:10:
      263|     else if isList dep then checkDependencyList' ([index] ++ positions) name dep
      264|     else throw "Dependency is not of a valid type: ${concatMapStrings (ix: "element ${toString ix} of ") ([index] ++ positions)}${name} for ${attrs.name or attrs.pname}");
         |          ^
      265| in if builtins.length erroneousHardeningFlags != 0

   error: Dependency is not of a valid type: element 2 of nativeBuildInputs for nix-shell

jbritton@pc19363:/mnt/c/Users/jbritton$

It is complaining about element 2, could it be a typo? Seems qt5full, should be qt5Full or qt5.full. I would however expect another failure regarding reference not existing…

What you did was install nix into an arbitrary WSL2 dist as per the instructions. Those commands were aimed to run inside WSL as you figured out.

You have to add that line to your bashrc in that dist where you installed Nix to have it part of your path every time.

Regarding the tarballs, that is part of the GitHub API, so that corresponds to a branch. It could be any branch or commit for the Nixpkgs repo.

If you are more serious about Nix+WSL, it is possible to run NixOS within WSL.

See GitHub - nix-community/NixOS-WSL: NixOS on WSL(2) [maintainer=@nzbr]

I modified the script to only fetch python3.12 and I get the same error.
It just feels like this version of Nix is broken.