nix-community / NixOS-WSL

NixOS on WSL(2) [maintainer=@nzbr]
Apache License 2.0
1.85k stars 118 forks source link

Errors while listing system generations #566

Open iainvm opened 2 weeks ago

iainvm commented 2 weeks ago

Bug description

When running nixos-rebuild list-generations --flake . --json I'm getting errors from the ls command

I think this might be happening because I used WSL2-Linux-Kernel-Rolling to update my kernel to get WSL Memory Reclaiming to work. So the kernel is coming up as unknown, but this is only a guess

To Reproduce

Install updated kernel Install NixOS WSL Use flakes for system Run nixos-rebuild list-generations --flake . --json

Logs

❯ nixos-rebuild list-generations --flake . --json        
ls: cannot access '/nix/store/0jdik0dwkivhfks4wd8hm0gj19ggynbz-nixos-system-potamoi-24.05.20240930.1719f27/lib/modules': No such file or directory
ls: cannot access '/nix/store/q42667alh58552sxiakxdy68hw5lfqpq-nixos-system-potamoi-24.05.20240930.1719f27/lib/modules': No such file or directory
ls: cannot access '/nix/store/dxvf9dn9w5xk6ivfsfdna168qcaq1nci-nixos-system-potamoi-24.05.20240930.1719f27/lib/modules': No such file or directory
ls: cannot access '/nix/store/0k8ywpi39xw1376pacj7mkbx061lfyin-nixos-system-potamoi-24.05.20240930.1719f27/lib/modules': No such file or directory
[
  {
    "generation": 17,
    "date": "2024-10-16T17:33:18Z",
    "nixosVersion": "24.05.20240930.1719f27",
    "kernelVersion": "Unknown",
    "configurationRevision": "",
    "specialisations": [
      "*"
    ],
    "current": true
  },
  ...
]

WSL version

WSL version: 2.3.24.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.19045.4894
SuperSandro2000 commented 1 week ago

A different kernel shouldn't matter.

You probably deleted the other store paths by accident and some symlinks are dangling. Try updating and the garbage collecting the nix store.

iainvm commented 1 week ago

As I add more to my config the more of these errors I see when listing the generations, and I'm only executing sudo nixos-rebuild switch --flake . I don't think I've been deleting any files in the /nix/ folder

nzbr commented 2 hours ago

I am able to reproduce that on my installation. My guess is that nixos-rebuild list-generations tries to look at what kernel modules are included in the generations (probably to determine the kernel version), but fails, because there are no kernel modules on NixOS-WSL because the kernel isn't managed by NixOS