[23.05.5] Sleepy Stoat
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
- Remove the old version of NixOS-WSL modules
sudo rm -rf /etc/nixos/nixos-wsl
- 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
- Update NixOS to 23.05
sudo nix-channel --add https://nixos.org/channels/nixos-23.05 nixos
- Update your channels
sudo nix-channel --update
- Adjust
configuration.nix
- Use the editor of your choice to edit
/etc/nixos/configuration.nix
(for examplesudo 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
- Remove the
- 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"; }
-
- Use the editor of your choice to edit
- Rebuild
sudo nixos-rebuild switch
- 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
- Refactor Code (#291) @nzbr
- Bump stable to 23.05 (#268) @SuperSandro2000
- Configure Renovate (#254) @renovate
🚀 Features
- New release preparation (#295) @K900
- feat: add a recovery shell (#274) @K900
- Allow customizing the system config to include in the tarball (#260) @terlar
- Include per-user applications in start menu launchers (#261) @terlar
- Enable systemd-timesyncd to prevent clock drift (#253) @SuperSandro2000
- Add default as an export from nixosModules (#251) @scottwillmoore
- wsl-conf: warn when networking.extraHosts has no effect (#233) @SuperSandro2000
- Add wsl.binShPkg and wsl.populateBin options to make envfs easily pos… (#211) @SuperSandro2000
- Use a Rust tool to do the PATH manipulations (#214) @K900
- Launch commands through a login shell (#182) @nzbr
- Use upstream settings instead of workarounds to disable unsupported settings (#175) @SuperSandro2000
- Add a
nixos-wsl-version
command (#183) @nzbr - syschdemd: Don't add an extra :, make robust against grep aliases (#197) @SuperSandro2000
- Disable powerManagement (#160) @SuperSandro2000
- Update remaining references to wsl.automountPath (#158) @nzbr
- Use proper option types for
wsl.conf
(#153) @nzbr - NixOS users.users. attribute name and .name can differ (#147) @KoviRobi
- Native systemd support (#134) @K900
- Rewrite syschdemd (#126) @K900
🪲 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