Skip to content

[23.05.5] Sleepy Stoat

Compare
Choose a tag to compare
@nzbr nzbr released this 29 Sep 22:21
· 185 commits to main since this release
8735bdf

Patch Notes

Native systemd support by default

With recent WSL releases, Microsoft added native support for running systemd inside WSL without container trickery. This release deprecates the old method container-based startup process (syschdemd) and uses WSL's native systemd support as the default. "Legacy" tarballs that use the old container trick are still available for now, but will likely go away with the next release.

Removing old workarounds

The wsl.docker-native and wsl.interop.preserveArgvZero options have been removed, as the workarounds they applied are no longer necessary. To run Docker inside of NixOS-WSL, simply enable virtualisation.docker.enable, like you would on any other NixOS system.

New tarball build process

The release tarballs built by NixOS-WSL no longer use a two-stage install process - you simply get a complete rootfs snapshot you can wsl --import directly. The tarball is also now built using conventional tools like nixos-install, to ensure the system ends up in a consistent state. This should not affect users in general, but users that want to build customized tarballs are encouraged to check the updated README.md.

Deprecating support for inbox versions of WSL

This release and all future releases will only support the Microsoft Store version of WSL.
To see if you have it installed, run wsl --version in PowerShell. If it does not report a version number, but complains about --version not being a recognized option, you are still running the "inbox" version of WSL that was shipped with Windows, and should upgrade to the Store version.

Distributing NixOS-WSL via channels instead of a local checkout

To make future updates less of a manual process, we are transitioning to distributing the WSL specific modules through a nix-channel. This will make sure, that you get the latest updates and bugfixes every time you run nix-channel --update. (If you are using flakes: You can keep on doing that. This doesn't affect you)

Recovering from "unshare: invalid argument"

The WSL 2.0 update introduced some changes to how the filesystem is set up, making NixOS-WSL's container tricks no longer work. If you encounter unshare: ...: invalid argument when starting NixOS-WSL, please follow the recovery steps detailed here before upgrading.

Should you encounter any problems, please open an issue. If you have any questions, feel free to start a discussion or join our chat

Migrating from 22.05 releases

  1. Remove the old version of NixOS-WSL modules
    • sudo rm -rf /etc/nixos/nixos-wsl
  2. Add the new version of NixOS-WSL as a channel
    • sudo nix-channel --add https://github.com/nix-community/NixOS-WSL/archive/refs/heads/main.tar.gz nixos-wsl
  3. Update NixOS to 23.05
    • sudo nix-channel --add https://nixos.org/channels/nixos-23.05 nixos
  4. Update your channels
    • sudo nix-channel --update
  5. Adjust configuration.nix
    • Use the editor of your choice to edit /etc/nixos/configuration.nix (for example sudo nano /etc/nixos/configuration.nix)
      • Remove the let ... in block at the start of the file
      • Remove the import from ${modulesPath}/profiles/minimal.nix
      • Change the import from nixos-wsl.nixosModules.wsl to <nixos-wsl/modules>
      • Remove nix.package = pkgs.nixFlakes; (you will still be able to use flakes, the alias is no longer necessary)
      • Do not touch system.stateVersion. Leave it on the version you first installed the system on
    • Save the file ([Ctrl]-[O], [Enter], [Ctrl]-[X] if you're using nano)
    • If you perform these steps on the default configuration that was included with the last release, it will now look like this
      • { lib, pkgs, config, modulesPath, ... }:
        
        with lib;
        {
          imports = [
            <nixos-wsl/modules>
          ];
        
          wsl = {
            enable = true;
            automountPath = "/mnt";
            defaultUser = "nixos";
            startMenuLaunchers = true;
                 
            # Enable integration with Docker Desktop (needs to be installed)
            # docker-desktop.enable = true;
        
          };
        
          # Enable nix flakes
          nix.extraOptions = ''
            experimental-features = nix-command flakes
          '';
        
          system.stateVersion = "22.05";
        }
  6. Rebuild
    • sudo nixos-rebuild switch
  7. Reboot NixOS
    • In PowerShell run:
    • wsl -t NixOS
    • wsl -d NixOS

If you are using Flakes

Update your flake inputs and make sure, that your NixOS version is at least set to 23.05.

If you import NixOS-WSL from a local directory, instead of as a flake input, you should add it to your flake's inputs instead, e.g.:

nixos-wsl.url = "github:nix-community/nixos-wsl";
nixos-wsl.inputs.nixpkgs.follows = "nixpkgs";

and import it as

inputs.nixos-wsl.nixosModules.wsl

Changelog

🛠️ General Changes

🚀 Features

🪲 Bugfixes

  • fix: getent missing in syschdemd (#267) @nzbr
  • fix: explicitly add systemctl and grep to path in shell-wrapper (#240) @K900
  • fix: just pull in the entire environment into the /bin/sh wrapper (#234) @K900
  • fix(installer): perl locale errrors (#228) @TeofilC
  • fix(split-paths): use standard library tools, fix shell quoting better (#219) @K900
  • fix: actually fix PATH filtering (#212) @K900
  • fix: ensure /nix/nixos-wsl exists before linking entrypoint (#208) @K900
  • fix: relink the X11 socket into place if needed (#207) @K900
  • fix: default user name isn't necessarily the same as user attr name (#204) @KoviRobi
  • fix: compatibility with latest WSL update (#199) @K900
  • fix: copy-launchers activation script (#181) @nzbr
  • fix(native-systemd): clean up /dev/shm correctly when it's a directory (#188) @K900
  • fix: flake lock (#186) @nzbr
  • fix: mount propagation (and also oomd) (#178) @K900
  • fix: X11 socket symlink creation (#172) @SuperSandro2000
  • fix: sudo ssh with jumpHost (#167) @SuperSandro2000
  • fix: permissions for files in /dev/pts (#166) @SuperSandro2000
  • fix: setting custom nameservers through networking.nameservers (#157) @nzbr
  • fix(native-systemd): pass arguments correctly (#170) @K900
  • fix: setup /bin/login for native systemd support (#169) @psmf
  • fix(syschdemd): exit code (#140) @nzbr
  • fix: disable module completely when wsl.enable = false (#151) @SuperSandro2000
  • fix(docker-native): switch nixpkgs.overlays to inline overlay (#150) @abehidek
  • fix: remove boot.isContainer (#145) @nzbr
  • fix: do not import minimal profile by default (#144) @SuperSandro2000

🧪 Tests