summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/main.yml22
-rw-r--r--.github/workflows/release.yml12
-rw-r--r--.gitignore2
-rw-r--r--README.md61
-rw-r--r--checks/username.nix4
-rw-r--r--configuration.nix32
-rw-r--r--flake.lock12
-rw-r--r--flake.nix47
-rw-r--r--modules/build-tarball.nix177
-rw-r--r--modules/default.nix12
-rw-r--r--modules/docker-desktop.nix (renamed from modules/docker/docker-desktop.nix)0
-rw-r--r--modules/docker/default.nix6
-rw-r--r--modules/docker/native.nix34
-rw-r--r--modules/installer.nix72
-rw-r--r--modules/interop.nix58
-rw-r--r--modules/recovery.nix4
-rw-r--r--modules/systemd/default.nix4
-rw-r--r--modules/systemd/syschdemd/syschdemd.sh2
-rw-r--r--modules/wsl-conf.nix2
-rw-r--r--modules/wsl-distro.nix7
-rw-r--r--tests/README.md10
-rw-r--r--tests/basic-functionality.Tests.ps14
-rw-r--r--tests/docker/docker-native.nix16
-rw-r--r--tests/docker/docker.Tests.ps11
-rw-r--r--tests/lib/Dockerfile2
-rw-r--r--tests/lib/lib.ps121
-rw-r--r--tests/login-shell/session-variables.nix6
-rw-r--r--tests/shells.Tests.ps19
-rw-r--r--tests/username-change/username-change.nix8
-rw-r--r--utils/Cargo.lock309
-rw-r--r--utils/Cargo.toml9
31 files changed, 393 insertions, 572 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 7baaef1..4ae011d 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -50,6 +50,12 @@ jobs:
needs:
- prepare
runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ config:
+ - modern
+ - legacy
+ - test
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -66,15 +72,17 @@ jobs:
echo ${{ needs.prepare.outputs.version }} > ./VERSION
echo $(git rev-parse HEAD) >> ./VERSION
- - name: Build installer ๐Ÿ› ๏ธ
+ - name: Build tarballs ๐Ÿ› ๏ธ
+ # We can't just nix run here because nix is not on root's PATH in the container
run: |
- nix build '.#nixosConfigurations.mysystem.config.system.build.installer'
+ nix build .#nixosConfigurations.${{ matrix.config }}.config.system.build.tarballBuilder
+ sudo ./result/bin/nixos-wsl-tarball-builder nixos-wsl.tar.gz
- - name: Upload installer ๐Ÿ“ค
+ - name: Upload tarball ๐Ÿ“ค
uses: actions/upload-artifact@v3
with:
- name: installer
- path: result/tarball/nixos-wsl-installer.tar.gz
+ name: tarball-${{ matrix.config }}
+ path: nixos-wsl.tar.gz
checks:
name: Flake Check ๐Ÿ“‹
@@ -117,10 +125,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- - name: Download installer ๐Ÿ“ฅ
+ - name: Download tarball ๐Ÿ“ฅ
uses: actions/download-artifact@v3
with:
- name: installer
+ name: tarball-test
- name: Execute test ๐Ÿงช
shell: pwsh
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 72ba873..ab862ea 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -14,13 +14,13 @@ jobs:
name: Create Release ๐Ÿ“ข
runs-on: ubuntu-latest
steps:
- - name: Download installer ๐Ÿ“ฅ
+ - name: Download tarball ๐Ÿ“ฅ
uses: actions/download-artifact@v3
- with:
- name: installer
- name: Generate checksums ๐Ÿ”‘
run: |
+ mv tarball-modern/nixos-wsl.tar.gz nixos-wsl.tar.gz
+ mv tarball-legacy/nixos-wsl.tar.gz nixos-wsl-legacy.tar.gz
for x in *.tar.gz; do
sha256sum $x > ${x}.sha256
done
@@ -29,7 +29,9 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: |
- nixos-wsl-installer.tar.gz
- nixos-wsl-installer.tar.gz.sha256
+ nixos-wsl.tar.gz
+ nixos-wsl.tar.gz.sha256
+ nixos-wsl-legacy.tar.gz
+ nixos-wsl-legacy.tar.gz.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.gitignore b/.gitignore
index c798a58..d6835c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
result
result-*
-nixos-wsl-installer.tar.gz
+nixos-wsl*.tar.gz
diff --git a/README.md b/README.md
index e2dad8f..695b858 100644
--- a/README.md
+++ b/README.md
@@ -9,18 +9,23 @@ A minimal root filesystem for running NixOS on WSL. It can be used with
[DistroLauncher](https://github.com/microsoft/WSL-DistroLauncher) as
`install.tar.gz` or as input to `wsl --import --version 2`.
+## System requirements
+
+NixOS-WSL is tested with the Windows Store version of WSL 2, which is now available on all supported Windows releases (both 10 and 11).
+Support for older "inbox" versions is best-effort.
+
## Quick start
-First, [download the latest release\'s installer](https://github.com/nix-community/NixOS-WSL/releases/latest).
+First, [download the latest release](https://github.com/nix-community/NixOS-WSL/releases/latest).
Then open up a Terminal, PowerShell or Command Prompt and run:
```sh
-wsl --import NixOS .\NixOS\ nixos-wsl-installer.tar.gz --version 2
+wsl --import NixOS .\NixOS\ nixos-wsl.tar.gz --version 2
```
This sets up a new WSL distribution `NixOS` that is installed under
-`.\NixOS`. `nixos-wsl-installer.tar.gz` is the path to the file you
+`.\NixOS`. `nixos-wsl.tar.gz` is the path to the file you
downloaded earlier. You might need to change this path or change to the download directory first.
You can now run NixOS:
@@ -29,11 +34,6 @@ You can now run NixOS:
wsl -d NixOS
```
-The installer will unpack the file system and subsequently start NixOS.
-A few warnings about file systems and locales will pop up. You can
-safely ignore them. After systemd has started, you should be greeted
-with a bash prompt inside your fresh NixOS installation.
-
If you want to make NixOS your default distribution, you can do so with
```sh
@@ -68,57 +68,34 @@ If you have a flakes-enabled Nix, you can use the following command to
build your own tarball instead of relying on a prebuilt one:
```cmd
-nix build github:nix-community/NixOS-WSL#nixosConfigurations.mysystem.config.system.build.installer
+sudo nix run github:nix-community/NixOS-WSL#nixosConfigurations.modern.config.system.build.tarballBuilder
```
Or, if you want to build with local changes, run inside your checkout:
```cmd
-nix build .#nixosConfigurations.mysystem.config.system.build.installer
+sudo nix run .#nixosConfigurations.your-hostname.config.system.build.tarballBuilder
```
Without a flakes-enabled Nix, you can build a tarball using:
```cmd
-nix-build -A nixosConfigurations.mysystem.config.system.build.installer
-```
+nix-build -A nixosConfigurations.mysystem.config.system.build.tarballBuilder && sudo ./result/bin/nixos-wsl-tarball-builder
-The resulting installer tarball can then be found under
-`./result/tarball/nixos-wsl-installer.tar.gz`.
+```
-You can also build a rootfs tarball without wrapping it in the installer
-by replacing `installer` with `tarball` in the above commands. The
-rootfs tarball can then be found under
-`./result/tarball/nixos-wsl-x86_64-linux.tar.gz`.
+The resulting tarball can then be found under `nixos-wsl.tar.gz`.
## Design
Getting NixOS to run under WSL requires some workarounds:
-### systemd support
-
-WSL comes with its own (non-substitutable) init system while NixOS uses
-systemd. Simply starting systemd later on does not work out of the box,
-because systemd as system instance refuses to start if it is not PID 1.
-This unfortunate combination is resolved in two ways:
-
-- the user\'s default shell is replaced by a wrapper script that acts
- is init system and then drops to the actual shell
-- systemd is started in its own PID namespace; therefore, it is PID 1.
- The shell wrapper (see above) enters the systemd namespace before
- dropping to the shell.
-
-### Installer
-
-Usually WSL distributions ship as a tarball of their root file system.
-These tarballs however, can not contain any hard-links due to the way
-they are unpacked by WSL, resulting in an \"Unspecified Error\". By
-default some Nix-derivations will contain hard-links when they are
-built. This results in system tarballs that can not be imported into
-WSL. To circumvent this problem, the rootfs tarball is wrapped in that
-of a minimal distribution (the installer), that is packaged without any
-hard-links. When the installer system is started for the first time, it
-overwrites itself with the contents of the rootfs tarball.
+- instead of directly loading systemd, we use a small shim that runs the NixOS activation scripts first
+- some additional binaries required by WSL's internal tooling are symlinked to FHS paths on activation
+
+Running on older WSL versions also requires a workaround to spawn systemd by hijacking the root shell and
+spawning a container with systemd inside. This method of running things is deprecated and not recommended,
+however still available as `nixos-wsl-legacy.tar.gz` or via `wsl.nativeSystemd = false`.
## License
diff --git a/checks/username.nix b/checks/username.nix
index 53337c7..2da4418 100644
--- a/checks/username.nix
+++ b/checks/username.nix
@@ -6,9 +6,9 @@
let
baseModule = { ... }: {
- imports = [ ../configuration.nix ];
-
+ imports = [ ../modules ];
wsl.enable = true;
+ wsl.defaultUser = "nixos";
};
changedUsername = { lib, ... }: {
wsl.defaultUser = lib.mkForce "different";
diff --git a/configuration.nix b/configuration.nix
deleted file mode 100644
index 789cf59..0000000
--- a/configuration.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-{ pkgs, ... }:
-
-let
- nixos-wsl = import ./default.nix;
-in
-{
- imports = [
- nixos-wsl.nixosModules.wsl
- ];
-
- wsl = {
- enable = true;
- wslConf.automount.root = "/mnt";
- defaultUser = "nixos";
- startMenuLaunchers = true;
-
- # Enable native Docker support
- # docker-native.enable = true;
-
- # Enable integration with Docker Desktop (needs to be installed)
- # docker-desktop.enable = true;
-
- };
-
- # Enable nix flakes
- nix.package = pkgs.nixFlakes;
- nix.extraOptions = ''
- experimental-features = nix-command flakes
- '';
-
- system.stateVersion = "23.05";
-}
diff --git a/flake.lock b/flake.lock
index 040e9b3..72e6ed4 100644
--- a/flake.lock
+++ b/flake.lock
@@ -21,11 +21,11 @@
"systems": "systems"
},
"locked": {
- "lastModified": 1692799911,
- "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
+ "lastModified": 1694529238,
+ "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
+ "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
@@ -36,11 +36,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1694048570,
- "narHash": "sha256-PEQptwFCVaJ+jLFJgrZll2shQ9VI/7xVhrCYkJo8iIw=",
+ "lastModified": 1695825837,
+ "narHash": "sha256-4Ne11kNRnQsmSJCRSSNkFRSnHC4Y5gPDBIQGjjPfJiU=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "4f77ea639305f1de0a14d9d41eef83313360638c",
+ "rev": "5cfafa12d57374f48bcc36fda3274ada276cf69e",
"type": "github"
},
"original": {
diff --git a/flake.nix b/flake.nix
index 66397e8..931f1e9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -26,11 +26,48 @@
};
nixosModules.default = self.nixosModules.wsl;
- nixosConfigurations.mysystem = nixpkgs.lib.nixosSystem {
- system = "x86_64-linux";
- modules = [
- ./configuration.nix
- ];
+ nixosConfigurations = {
+ modern = nixpkgs.lib.nixosSystem {
+ system = "x86_64-linux";
+ modules = [
+ self.nixosModules.default
+ { wsl.enable = true; }
+ ];
+ };
+
+ legacy = nixpkgs.lib.nixosSystem {
+ system = "x86_64-linux";
+ modules = [
+ self.nixosModules.default
+ {
+ wsl.enable = true;
+ wsl.nativeSystemd = false;
+ }
+ ];
+ };
+
+ test = nixpkgs.lib.nixosSystem {
+ system = "x86_64-linux";
+ modules = [
+ self.nixosModules.default
+ ({ config, pkgs, ... }: {
+ wsl.enable = true;
+ wsl.nativeSystemd = false;
+
+ system.activationScripts.create-test-entrypoint.text =
+ let
+ syschdemdProxy = pkgs.writeShellScript "syschdemd-proxy" ''
+ shell=$(${pkgs.glibc.bin}/bin/getent passwd root | ${pkgs.coreutils}/bin/cut -d: -f7)
+ exec $shell $@
+ '';
+ in
+ ''
+ mkdir -p /bin
+ ln -sfn ${syschdemdProxy} /bin/syschdemd
+ '';
+ })
+ ];
+ };
};
} //
diff --git a/modules/build-tarball.nix b/modules/build-tarball.nix
index d2e5231..f48c9ce 100644
--- a/modules/build-tarball.nix
+++ b/modules/build-tarball.nix
@@ -1,112 +1,95 @@
{ config, pkgs, lib, ... }:
with builtins; with lib;
let
- cfg = config.wsl.tarball;
-
- pkgs2storeContents = l: map (x: { object = x; symlink = "none"; }) l;
-
- nixpkgs = lib.cleanSource pkgs.path;
-
- channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}"
- { preferLocalBuild = true; }
- ''
- mkdir -p $out
- cp -prd ${nixpkgs.outPath} $out/nixos
- chmod -R u+w $out/nixos
- if [ ! -e $out/nixos/nixpkgs ]; then
- ln -s . $out/nixos/nixpkgs
- fi
- echo -n ${toString config.system.nixos.revision} > $out/nixos/.git-revision
- echo -n ${toString config.system.nixos.versionSuffix} > $out/nixos/.version-suffix
- echo ${toString config.system.nixos.versionSuffix} | sed -e s/pre// > $out/nixos/svn-revision
- '';
-
- preparer = pkgs.writeShellScriptBin "wsl-prepare" (''
- set -e
-
- mkdir -m 0755 ./bin ./etc
- mkdir -m 1777 ./tmp
-
- # WSL requires a /bin/sh - only temporary, NixOS's activate will overwrite
- ln -s ${config.users.users.root.shell} ./bin/sh
-
- # WSL also requires a /bin/mount, otherwise the host fs isn't accessible
- ln -s /nix/var/nix/profiles/system/sw/bin/mount ./bin/mount
-
- # Set system profile
- system=${config.system.build.toplevel}
- ./$system/sw/bin/nix-store --store `pwd` --load-db < ./nix-path-registration
- rm ./nix-path-registration
- ./$system/sw/bin/nix-env --store `pwd` -p ./nix/var/nix/profiles/system --set $system
-
- # Set channel
- mkdir -p ./nix/var/nix/profiles/per-user/root
- ./$system/sw/bin/nix-env --store `pwd` -p ./nix/var/nix/profiles/per-user/root/channels --set ${channelSources}
- mkdir -m 0700 -p ./root/.nix-defexpr
- ln -s /nix/var/nix/profiles/per-user/root/channels ./root/.nix-defexpr/channels
-
- # It's now a NixOS!
- touch ./etc/NIXOS
-
- # Write wsl.conf so that it is present when NixOS is started for the first time
- cp ${config.environment.etc."wsl.conf".source} ./etc/wsl.conf
-
- '' + lib.optionalString cfg.includeConfig ''
- ${if cfg.configPath == null then ''
- # Copy the system configuration
- mkdir -p ./etc/nixos/nixos-wsl
- cp -R ${lib.cleanSource ../.}/. ./etc/nixos/nixos-wsl
- mv ./etc/nixos/nixos-wsl/configuration.nix ./etc/nixos/configuration.nix
- # Patch the import path to avoid having a flake.nix in /etc/nixos
- sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix
- '' else ''
- mkdir -p ./etc/nixos
- cp -R ${lib.cleanSource cfg.configPath}/. ./etc/nixos
- ''}
- chmod -R u+w etc/nixos
- '');
+ cfg = config.wsl;
-in
-{
-
- options.wsl.tarball = {
- includeConfig = mkOption {
- type = types.bool;
- default = true;
- description = "Whether or not to copy the system configuration into the tarball";
- };
-
- configPath = mkOption {
- type = types.nullOr types.path;
- default = null;
- description = "Path to system configuration which is copied into the tarball";
- };
- };
+ defaultConfig = pkgs.writeText "default-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 = mkIf config.wsl.enable {
- # These options make no sense without the wsl-distro module anyway
+ { config, lib, pkgs, ... }:
- system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" {
-
- contents = [
- { source = config.users.users.root.shell; target = "/nix/nixos-wsl/entrypoint"; }
+ {
+ imports = [
+ # include NixOS-WSL modules
+ <nixos-wsl/modules>
];
- fileName = "nixos-wsl-${pkgs.hostPlatform.system}";
+ wsl.enable = true;
+ wsl.defaultUser = "nixos";
+ ${cfg.extraTarballConfig}
+
+ # 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 = "${config.system.nixos.release}"; # Did you read the comment?
+ }
+ '';
+in
+{
+ options.wsl.extraTarballConfig = mkOption {
+ type = types.str;
+ internal = true;
+ default = "";
+ };
- storeContents = pkgs2storeContents [
- config.system.build.toplevel
- channelSources
- preparer
- ];
+ # These options make no sense without the wsl-distro module anyway
+ config = mkIf cfg.enable {
+ system.build.tarballBuilder = pkgs.writeShellApplication {
+ name = "nixos-wsl-tarball-builder";
- extraCommands = "${preparer}/bin/wsl-prepare";
+ runtimeInputs = [
+ pkgs.coreutils
+ pkgs.gnutar
+ pkgs.nixos-install-tools
+ config.nix.package
+ ];
- # Use gzip
- compressCommand = "gzip";
- compressionExtension = ".gz";
+ text = ''
+ if ! [ $EUID -eq 0 ]; then
+ echo "This script must be run as root!"
+ exit 1
+ fi
+
+ out=''${1:-nixos-wsl.tar.gz}
+
+ root=$(mktemp -p "''${TMPDIR:-/tmp}" -d nixos-wsl-tarball.XXXXXXXXXX)
+ # FIXME: fails in CI for some reason, but we don't really care because it's CI
+ trap 'rm -rf "$root" || true' INT TERM EXIT
+
+ chmod o+rx "$root"
+
+ echo "[NixOS-WSL] Installing..."
+ nixos-install \
+ --root "$root" \
+ --no-root-passwd \
+ --system ${config.system.build.toplevel} \
+ --substituters ""
+
+ echo "[NixOS-WSL] Adding channel..."
+ nixos-enter --root "$root" --command 'nix-channel --add https://github.com/nix-community/NixOS-WSL/archive/refs/heads/main.tar.gz nixos-wsl'
+
+ echo "[NixOS-WSL] Adding default config..."
+ install -Dm644 ${defaultConfig} "$root/etc/nixos/configuration.nix"
+
+ echo "[NixOS-WSL] Compressing..."
+ tar -C "$root" \
+ -cz \
+ --sort=name \
+ --mtime='@1' \
+ --owner=0 \
+ --group=0 \
+ --numeric-owner \
+ . \
+ > "$out"
+ '';
};
-
};
}
diff --git a/modules/default.nix b/modules/default.nix
index 0278634..08a612a 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -1,13 +1,19 @@
-{ ... }: {
+{ lib, ... }: {
imports = [
./build-tarball.nix
- ./docker
- ./installer.nix
+ ./docker-desktop.nix
./interop.nix
./recovery.nix
./systemd
./version.nix
./wsl-conf.nix
./wsl-distro.nix
+
+ (lib.mkRemovedOptionModule [ "wsl" "docker-native" ]
+ "Additional workarounds are no longer required for Docker to work. Please use the standard `virtualisation.docker` NixOS options.")
+ (lib.mkRemovedOptionModule [ "wsl" "interop" "preserveArgvZero" ]
+ "wsl.interop.preserveArgvZero is now always enabled, as used by modern WSL versions.")
+ (lib.mkRemovedOptionModule [ "wsl" "tarball" ]
+ "The tarball is now always generated with a default configuration.nix.")
];
}
diff --git a/modules/docker/docker-desktop.nix b/modules/docker-desktop.nix
index e2ae076..e2ae076 100644
--- a/modules/docker/docker-desktop.nix
+++ b/modules/docker-desktop.nix
diff --git a/modules/docker/default.nix b/modules/docker/default.nix
deleted file mode 100644
index 176b95b..0000000
--- a/modules/docker/default.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ ... }: {
- imports = [
- ./docker-desktop.nix
- ./native.nix
- ];
-}
diff --git a/modules/docker/native.nix b/modules/docker/native.nix
deleted file mode 100644
index 88f48d9..0000000
--- a/modules/docker/native.nix
+++ /dev/null
@@ -1,34 +0,0 @@
-{ config, lib, pkgs, ... }:
-with builtins; with lib; {
-
- options.wsl.docker-native = with types; {
- enable = mkEnableOption "Native Docker integration in NixOS.";
-
- addToDockerGroup = mkOption {
- type = bool;
- default = config.security.sudo.wheelNeedsPassword;
- description = ''
- Wether to add the default user to the docker group.
-
- This is not recommended, if you have a password, because it essentially permits unauthenticated root access.
- '';
- };
- };
-
- config =
- let
- cfg = config.wsl.docker-native;
- in
- mkIf (config.wsl.enable && cfg.enable) {
- environment.systemPackages = with pkgs; [
- docker-compose
- ];
-
- virtualisation.docker.package = (pkgs.docker.override { iptables = pkgs.iptables-legacy; });
- virtualisation.docker.enable = true;
-
- users.groups.docker.members = lib.mkIf cfg.addToDockerGroup [
- config.wsl.defaultUser
- ];
- };
-}
diff --git a/modules/installer.nix b/modules/installer.nix
deleted file mode 100644
index 74cd7b2..0000000
--- a/modules/installer.nix
+++ /dev/null
@@ -1,72 +0,0 @@
-{ config, lib, pkgs, ... }:
-with builtins; with lib; {
-
- config = mkIf config.wsl.enable (
- let
- mkTarball = pkgs.callPackage "${lib.cleanSource pkgs.path}/nixos/lib/make-system-tarball.nix";
-
- pkgs2storeContents = map (x: { object = x; symlink = "none"; });
-
- rootfs = let tarball = config.system.build.tarball; in "${tarball}/tarball/${tarball.fileName}.tar${tarball.extension}";
-
- installer = pkgs.writeScript "installer.sh" ''
- #!${pkgs.busybox}/bin/sh
- BASEPATH=$PATH
- export PATH=$BASEPATH:${pkgs.busybox}/bin # Add busybox to path
-
- set -e
- cd /
-
- echo "Unpacking root file system..."
- ${pkgs.pv}/bin/pv ${rootfs} | tar xz
-
- echo "Activating nix configuration..."
- LANG="C.UTF-8" /nix/var/nix/profiles/system/activate
- PATH=$BASEPATH:/run/current-system/sw/bin # Use packages from target system
-
- echo "Cleaning up installer files..."
- nix-collect-garbage
- rm /nix-path-registration
-
- echo "Optimizing store..."
- nix-store --optimize
-
- # Don't package the shell here, it's contained in the rootfs
- exec ${builtins.unsafeDiscardStringContext config.users.users.root.shell} "$@"
- '';
-
- # Set installer.sh as the root shell
- passwd = pkgs.writeText "passwd" ''
- root:x:0:0:System administrator:/root:${installer}
- '';
- in
- {
-
- system.build.installer = mkTarball {
- fileName = "nixos-wsl-installer";
- compressCommand = "gzip";
- compressionExtension = ".gz";
- extraArgs = "--hard-dereference";
-
- storeContents = pkgs2storeContents [ installer ];
-
- contents = [
- { source = config.environment.etc."wsl.conf".source; target = "/etc/wsl.conf"; }
- { source = config.environment.etc."fstab".source; target = "/etc/fstab"; }
- { source = passwd; target = "/etc/passwd"; }
- { source = "${pkgs.busybox}/bin/busybox"; target = "/bin/sh"; }
- { source = "${pkgs.busybox}/bin/busybox"; target = "/bin/mount"; }
- { source = "${installer}"; target = "/nix/nixos-wsl/entrypoint"; }
- ];
-
- extraCommands = pkgs.writeShellScript "prepare" ''
- export PATH=$PATH:${pkgs.coreutils}/bin
- mkdir -p bin
- ln -s /init bin/wslpath
- '';
- };
-
- }
- );
-
-}
diff --git a/modules/interop.nix b/modules/interop.nix
index d055d4b..bcd3040 100644
--- a/modules/interop.nix
+++ b/modules/interop.nix
@@ -1,11 +1,7 @@
-{ lib, pkgs, config, ... }:
+{ lib, config, ... }:
with builtins; with lib;
{
- imports = [
- (mkRenamedOptionModule [ "wsl" "compatibility" "interopPreserveArgvZero" ] [ "wsl" "interop" "preserveArgvZero" ])
- ];
-
options.wsl.interop = with types; {
register = mkOption {
type = bool;
@@ -18,18 +14,6 @@ with builtins; with lib;
default = true;
description = "Include Windows PATH in WSL PATH";
};
-
- preserveArgvZero = mkOption {
- type = nullOr bool;
- default = null;
- description = ''
- Register binfmt interpreter for Windows executables with 'preserves argv[0]' flag.
-
- Default (null): autodetect, at some performance cost.
- To avoid the performance cost, set this to true for WSL Preview 0.58 and up,
- or to false for any older versions, including pre-Microsoft Store and Windows 10.
- '';
- };
};
config =
@@ -39,39 +23,13 @@ with builtins; with lib;
mkIf config.wsl.enable {
boot.binfmt.registrations = mkIf cfg.register {
- WSLInterop =
- let
- compat = cfg.preserveArgvZero;
-
- # WSL Preview 0.58 and up registers the /init binfmt interp for Windows executable
- # with the "preserve argv[0]" flag, so if you run `./foo.exe`, the interp gets invoked
- # as `/init foo.exe ./foo.exe`.
- # argv[0] --^ ^-- actual path
- #
- # Older versions expect to be called without the argv[0] bit, simply as `/init ./foo.exe`.
- #
- # We detect that by running `/init /known-not-existing-path.exe` and checking the exit code:
- # the new style interp expects at least two arguments, so exits with exit code 1,
- # presumably meaning "parsing error"; the old style interp attempts to actually run
- # the executable, fails to find it, and exits with 255.
- compatWrapper = pkgs.writeShellScript "nixos-wsl-binfmt-hack" ''
- /init /nixos-wsl-does-not-exist.exe
- [ $? -eq 255 ] && shift
- exec /init "$@"
- '';
-
- # use the autodetect hack if unset, otherwise call /init directly
- interpreter = if compat == null then compatWrapper else "/init";
-
- # enable for the wrapper and autodetect hack
- preserveArgvZero = if compat == false then false else true;
- in
- {
- magicOrExtension = "MZ";
- fixBinary = true;
- wrapInterpreterInShell = false;
- inherit interpreter preserveArgvZero;
- };
+ WSLInterop = {
+ magicOrExtension = "MZ";
+ fixBinary = true;
+ wrapInterpreterInShell = false;
+ interpreter = "/init";
+ preserveArgvZero = true;
+ };
};
warnings =
diff --git a/modules/recovery.nix b/modules/recovery.nix
index ec29da6..2352d51 100644
--- a/modules/recovery.nix
+++ b/modules/recovery.nix
@@ -1,7 +1,5 @@
-{ config, pkgs, lib, ... }:
-with lib;
+{ config, pkgs, ... }:
let
-
nixos-enter' = config.system.build.nixos-enter.overrideAttrs (_: {
runtimeShell = "/bin/bash";
});
diff --git a/modules/systemd/default.nix b/modules/systemd/default.nix
index c6c2337..9199bcb 100644
--- a/modules/systemd/default.nix
+++ b/modules/systemd/default.nix
@@ -1,4 +1,4 @@
-{ config, pkgs, lib, ... }:
+{ config, lib, ... }:
with lib; {
imports = [
@@ -9,7 +9,7 @@ with lib; {
options.wsl = with types; {
nativeSystemd = mkOption {
type = bool;
- default = false;
+ default = true;
description = "Use native WSL systemd support";
};
};
diff --git a/modules/systemd/syschdemd/syschdemd.sh b/modules/systemd/syschdemd/syschdemd.sh
index fa0ffe5..75f10aa 100644
--- a/modules/systemd/syschdemd/syschdemd.sh
+++ b/modules/systemd/syschdemd/syschdemd.sh
@@ -38,6 +38,8 @@ run_in_namespace() {
}
start_systemd() {
+ mount --bind --make-private $rundir $rundir
+
daemonize \
-o $rundir/stdout \
-e $rundir/stderr \
diff --git a/modules/wsl-conf.nix b/modules/wsl-conf.nix
index 0058f29..877041a 100644
--- a/modules/wsl-conf.nix
+++ b/modules/wsl-conf.nix
@@ -1,4 +1,4 @@
-{ lib, pkgs, config, ... }:
+{ lib, config, ... }:
with lib; {
imports = [
diff --git a/modules/wsl-distro.nix b/modules/wsl-distro.nix
index 0b7648d..f2279e3 100644
--- a/modules/wsl-distro.nix
+++ b/modules/wsl-distro.nix
@@ -1,4 +1,4 @@
-{ lib, pkgs, config, options, ... }:
+{ lib, pkgs, config, ... }:
with builtins; with lib;
@@ -132,11 +132,6 @@ in
config.wsl.extraBin
)}
'');
- # TODO: This is only needed for the docker tests, it can be removed when they are moved to something else
- update-entrypoint.text = ''
- mkdir -p /nix/nixos-wsl
- ln -sfn ${config.users.users.root.shell} /nix/nixos-wsl/entrypoint
- '';
};
# require people to use lib.mkForce to make it harder to brick their installation
diff --git a/tests/README.md b/tests/README.md
index d285809..7c5eb92 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -1,7 +1,7 @@
# Tests
-This directory contains tests that are executed against a built installer tarball.
-The test are written using the [Pester](https://pester.dev/) testing framework
+This directory contains tests that are executed against a built NixOS-WSL "legacy" tarball.
+The tests are written using the [Pester](https://pester.dev/) testing framework.
## Execute Tests
@@ -19,7 +19,9 @@ Running the tests requires Docker and PowerShell to be installed on your system.
### Running the Tests
If you haven't already, [install Pester](https://pester.dev/docs/introduction/installation/).
-The tests require a `nixos-wsl-installer.tar.gz` to be present in the current working directory or in `./result/tarball`. Refer to the top-level readme on how to build it.
+The tests require a "legacy" `nixos-wsl.tar.gz` to be present in the current working directory, which can be built with
+`sudo nix run .#nixosConfigurations.legacy.config.system.build.tarballBuilder -- nixos-wsl.tar.gz`.
+
Once everything is in place, run the test by running the following in PowerShell at the root of this repo:
```powershell
@@ -44,6 +46,6 @@ BeforeAll {
- A Distro object has the following methods:
- `Launch($command)`: Runs the specified command inside the container. Returns the command output
- `GetPath($path)`: Returns the path inside the container, that points to the specified file on the host.
- - `InstallConfig($path)`: Installs a nix-file as the systems `configuration.nix`. The default configuration is moved to `base.nix`, so that it can be imported by the new config
+ - `InstallConfig($path)`: Installs a nix-file as the systems `configuration.nix`.
- `Shutdown()`: End all processes running in the container
- `Uninstall()`: Stop and then delete the container from the system. This should be called in an AfterEach or AfterAll block, so that the test does not leave it on the system.
diff --git a/tests/basic-functionality.Tests.ps1 b/tests/basic-functionality.Tests.ps1
index d62823b..9459b15 100644
--- a/tests/basic-functionality.Tests.ps1
+++ b/tests/basic-functionality.Tests.ps1
@@ -7,7 +7,7 @@ Describe "Basic Functionality" {
$distro = Install-Distro
}
- It "is possible to run a command through the installer" {
+ It "is possible to run a command in the container" {
$distro.Launch("nixos-version")
$LASTEXITCODE | Should -Be 0
}
@@ -34,7 +34,7 @@ Describe "Basic Functionality" {
}
It "is possible to run a command through nix run" {
- $distro.Launch("nix run nixpkgs#neofetch")
+ $distro.Launch("nix --extra-experimental-features 'nix-command flakes' run nixpkgs#neofetch")
$LASTEXITCODE | Should -Be 0
}
diff --git a/tests/docker/docker-native.nix b/tests/docker/docker-native.nix
index 47ccb7f..f119482 100644
--- a/tests/docker/docker-native.nix
+++ b/tests/docker/docker-native.nix
@@ -1,12 +1,14 @@
-{ pkgs, lib, ... }:
{
- imports = [ ./base.nix ];
+ imports = [
+ <nixos-wsl/modules>
+ ];
- wsl.docker-native.enable = true;
- wsl.docker-native.addToDockerGroup = true;
+ wsl.enable = true;
+ users.users.nixos.extraGroups = [ "docker" ];
- # Github Actions runners try to use aufs and fail if this is not set explicitly
- virtualisation.docker.daemon.settings = {
- "storage-driver" = "vfs";
+ virtualisation.docker = {
+ enable = true;
+ # Github Actions runners try to use aufs and fail if this is not set explicitly
+ daemon.settings."storage-driver" = "vfs";
};
}
diff --git a/tests/docker/docker.Tests.ps1 b/tests/docker/docker.Tests.ps1
index fefff07..9ea46aa 100644
--- a/tests/docker/docker.Tests.ps1
+++ b/tests/docker/docker.Tests.ps1
@@ -27,7 +27,6 @@ Describe "Docker (native)" {
It "should be possible to connect to the internet from a container" {
$distro.Launch("docker run --rm -it alpine wget -qO- http://www.msftconnecttest.com/connecttest.txt") | Select-Object -Last 1 | Should -BeExactly "Microsoft Connect Test"
- # docker exec -it $distro.id /nix/nixos-wsl/entrypoint -c "docker run --rm -it alpine wget -qO- http://www.msftconnecttest.com/connecttest.txt" | Select-Object -Last 1 | Should -BeExactly "Microsoft Connect Test"
$LASTEXITCODE | Should -Be 0
}
diff --git a/tests/lib/Dockerfile b/tests/lib/Dockerfile
index 1fcea66..e703915 100644
--- a/tests/lib/Dockerfile
+++ b/tests/lib/Dockerfile
@@ -1,2 +1,2 @@
FROM scratch
-ADD nixos-wsl-installer.tar.gz /
+ADD nixos-wsl.tar.gz /
diff --git a/tests/lib/lib.ps1 b/tests/lib/lib.ps1
index 58b1a42..e3985c9 100644
--- a/tests/lib/lib.ps1
+++ b/tests/lib/lib.ps1
@@ -26,12 +26,9 @@ class Distro {
[string]FindTarball() {
# Check if a fresh tarball exists in result, otherwise try one in the current directory
- $tarball = "./result/tarball/nixos-wsl-installer.tar.gz"
+ $tarball = "./nixos-wsl.tar.gz"
if (!(Test-Path $tarball)) {
- $tarball = "./nixos-wsl-installer.tar.gz"
- if (!(Test-Path $tarball)) {
- throw "Could not find the installer tarball! Run nix build first, or place one in the current directory."
- }
+ throw "Could not find the tarball! Run nix build first, or place one in the current directory."
}
Write-Host "Using tarball: $tarball"
return $tarball
@@ -40,10 +37,6 @@ class Distro {
[void]InstallConfig([string]$path) {
Write-Host "Installing config: $path"
- # Move config out of the way
- $this.Launch("/bin/sh -c 'test -f /etc/nixos/base.nix || sudo mv /etc/nixos/configuration.nix /etc/nixos/base.nix'")
- $LASTEXITCODE | Should -Be 0
-
# Copy the new config
$this.Launch("sudo cp $($this.GetPath($path)) /etc/nixos/configuration.nix")
$LASTEXITCODE | Should -Be 0
@@ -75,7 +68,7 @@ class DockerDistro : Distro {
$tarball = $this.FindTarball()
if (!([DockerDistro]::imageCreated)) {
- # Build docker image from the installer tarball
+ # Build docker image from the tarball
$tmpdir = $(mktemp -d)
Copy-Item $PSScriptRoot/Dockerfile $tmpdir
Copy-Item $tarball $tmpdir
@@ -91,12 +84,14 @@ class DockerDistro : Distro {
if ($LASTEXITCODE -ne 0) {
throw "Failed to launch container"
}
+
+ $this.Launch("sudo nix-channel --update")
}
[Array]Launch([string]$command) {
Write-Host "> $command"
$result = @()
- docker exec -t $this.id /nix/nixos-wsl/entrypoint -c $command | Tee-Object -Variable result | Write-Host
+ docker exec -t $this.id /bin/syschdemd -c $command | Tee-Object -Variable result | Write-Host
return $result | Remove-Escapes
}
@@ -135,12 +130,14 @@ class WslDistro : Distro {
throw "Failed to import distro"
}
& wsl.exe --list | Should -Contain $this.id
+
+ $this.Launch("sudo nix-channel --update")
}
[Array]Launch([string]$command) {
Write-Host "> $command"
$result = @()
- & wsl.exe -d $this.id -e /nix/nixos-wsl/entrypoint -c $command | Tee-Object -Variable result | Write-Host
+ & wsl.exe -d $this.id -e /bin/syschdemd -c $command | Tee-Object -Variable result | Write-Host
return $result | Remove-Escapes
}
diff --git a/tests/login-shell/session-variables.nix b/tests/login-shell/session-variables.nix
index d6525ed..6829bbf 100644
--- a/tests/login-shell/session-variables.nix
+++ b/tests/login-shell/session-variables.nix
@@ -1,13 +1,15 @@
-{ config, pkgs, lib, ... }:
+{ pkgs, lib, ... }:
let
ver = with lib; substring 0 5 version;
in
{
imports = [
- ./base.nix
+ <nixos-wsl/modules>
"${builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-${ver}.tar.gz"}/nixos"
];
+ wsl.enable = true;
+
home-manager.users.nixos = { ... }: {
home = {
stateVersion = ver;
diff --git a/tests/shells.Tests.ps1 b/tests/shells.Tests.ps1
index 184014b..6bcc640 100644
--- a/tests/shells.Tests.ps1
+++ b/tests/shells.Tests.ps1
@@ -11,10 +11,15 @@ Describe "Shells" {
@"
{ pkgs, lib, config, options, ... }:
with lib; {
- imports = [ ./base.nix ];
+ imports = [
+ <nixos-wsl/modules>
+ ];
config = mkMerge [
- { users.users.`${config.wsl.defaultUser}.shell = pkgs.$package; }
+ {
+ wsl.enable = true;
+ users.users.nixos.shell = pkgs.$package;
+ }
(optionalAttrs (hasAttrByPath ["programs" "$package" "enable"] options) {
programs.$package.enable = true;
})
diff --git a/tests/username-change/username-change.nix b/tests/username-change/username-change.nix
index 77a2cdd..32d7e1e 100644
--- a/tests/username-change/username-change.nix
+++ b/tests/username-change/username-change.nix
@@ -1,6 +1,8 @@
-{ pkgs, lib, ... }:
{
- imports = [ ./base.nix ];
+ imports = [
+ <nixos-wsl/modules>
+ ];
- wsl.defaultUser = lib.mkForce "different-name";
+ wsl.enable = true;
+ wsl.defaultUser = "different-name";
}
diff --git a/utils/Cargo.lock b/utils/Cargo.lock
index cd84378..51e6b4b 100644
--- a/utils/Cargo.lock
+++ b/utils/Cargo.lock
@@ -4,9 +4,9 @@ version = 3
[[package]]
name = "addr2line"
-version = "0.17.0"
+version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b"
+checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
dependencies = [
"gimli",
]
@@ -18,6 +18,55 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
+name = "anstream"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is-terminal",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c"
+dependencies = [
+ "anstyle",
+ "windows-sys",
+]
+
+[[package]]
name = "anyhow"
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -28,9 +77,9 @@ dependencies = [
[[package]]
name = "backtrace"
-version = "0.3.66"
+version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7"
+checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
dependencies = [
"addr2line",
"cc",
@@ -43,21 +92,18 @@ dependencies = [
[[package]]
name = "bitflags"
-version = "1.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
-
-[[package]]
-name = "bitflags"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "cc"
-version = "1.0.73"
+version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
+dependencies = [
+ "libc",
+]
[[package]]
name = "cfg-if"
@@ -67,27 +113,34 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
-version = "4.1.4"
+version = "4.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76"
+checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487"
dependencies = [
- "bitflags 1.3.2",
+ "clap_builder",
"clap_derive",
- "clap_lex",
- "is-terminal",
"once_cell",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.3.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "clap_lex",
"strsim",
- "termcolor",
]
[[package]]
name = "clap_derive"
-version = "4.1.0"
+version = "4.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8"
+checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050"
dependencies = [
"heck",
- "proc-macro-error",
"proc-macro2",
"quote",
"syn",
@@ -95,22 +148,25 @@ dependencies = [
[[package]]
name = "clap_lex"
-version = "0.3.1"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade"
-dependencies = [
- "os_str_bytes",
-]
+checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "errno"
-version = "0.2.8"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
+checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
dependencies = [
"errno-dragonfly",
"libc",
- "winapi",
+ "windows-sys",
]
[[package]]
@@ -125,43 +181,29 @@ dependencies = [
[[package]]
name = "gimli"
-version = "0.26.2"
+version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
+checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]]
name = "heck"
-version = "0.4.0"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
+checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
-version = "0.2.6"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "io-lifetimes"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e"
-dependencies = [
- "libc",
- "windows-sys",
-]
+checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
[[package]]
name = "is-terminal"
-version = "0.4.2"
+version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"
+checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
- "io-lifetimes",
"rustix",
"windows-sys",
]
@@ -178,15 +220,15 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.147"
+version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
+checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "linux-raw-sys"
-version = "0.1.4"
+version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
+checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128"
[[package]]
name = "log"
@@ -196,15 +238,15 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "memchr"
-version = "2.5.0"
+version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
+checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "miniz_oxide"
-version = "0.5.4"
+version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
+checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
dependencies = [
"adler",
]
@@ -215,7 +257,7 @@ version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
- "bitflags 2.4.0",
+ "bitflags",
"cfg-if",
"libc",
]
@@ -224,8 +266,11 @@ dependencies = [
name = "nixos-wsl-utils"
version = "0.1.0"
dependencies = [
+ "anstyle",
+ "anstyle-parse",
"anyhow",
"clap",
+ "clap_lex",
"kernlog",
"log",
"nix",
@@ -233,82 +278,51 @@ dependencies = [
[[package]]
name = "object"
-version = "0.29.0"
+version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
+checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
-version = "1.17.0"
+version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
-
-[[package]]
-name = "os_str_bytes"
-version = "6.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
-
-[[package]]
-name = "proc-macro-error"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
-dependencies = [
- "proc-macro-error-attr",
- "proc-macro2",
- "quote",
- "syn",
- "version_check",
-]
-
-[[package]]
-name = "proc-macro-error-attr"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
-dependencies = [
- "proc-macro2",
- "quote",
- "version_check",
-]
+checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "proc-macro2"
-version = "1.0.50"
+version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2"
+checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.23"
+version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rustc-demangle"
-version = "0.1.21"
+version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
+checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustix"
-version = "0.36.7"
+version = "0.38.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03"
+checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"errno",
- "io-lifetimes",
"libc",
"linux-raw-sys",
"windows-sys",
@@ -322,9 +336,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
-version = "1.0.107"
+version = "2.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
+checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8"
dependencies = [
"proc-macro2",
"quote",
@@ -332,62 +346,31 @@ dependencies = [
]
[[package]]
-name = "termcolor"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
-dependencies = [
- "winapi-util",
-]
-
-[[package]]
name = "unicode-ident"
-version = "1.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
-
-[[package]]
-name = "version_check"
-version = "0.9.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
-
-[[package]]
-name = "winapi"
-version = "0.3.9"
+version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
-dependencies = [
- "winapi-i686-pc-windows-gnu",
- "winapi-x86_64-pc-windows-gnu",
-]
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
-name = "winapi-i686-pc-windows-gnu"
-version = "0.4.0"
+name = "utf8parse"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
-name = "winapi-util"
-version = "0.1.5"
+name = "windows-sys"
+version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
- "winapi",
+ "windows-targets",
]
[[package]]
-name = "winapi-x86_64-pc-windows-gnu"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-
-[[package]]
-name = "windows-sys"
-version = "0.42.0"
+name = "windows-targets"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
@@ -400,42 +383,42 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
-version = "0.42.1"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
-version = "0.42.1"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
-version = "0.42.1"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
-version = "0.42.1"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
-version = "0.42.1"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
-version = "0.42.1"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
-version = "0.42.1"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
diff --git a/utils/Cargo.toml b/utils/Cargo.toml
index 6fac1a1..c80880d 100644
--- a/utils/Cargo.toml
+++ b/utils/Cargo.toml
@@ -2,13 +2,20 @@
name = "nixos-wsl-utils"
version = "0.1.0"
edition = "2021"
+# Keep this in sync with NixOS stable
+rust-version = "1.69.0"
[dependencies]
anyhow = { version = "1.0.75", features = ["backtrace"] }
nix = { version = "0.27.1", features = ["mount", "process"] }
log = "0.4.20"
kernlog = "0.3.1"
-clap = { version = "4.1.4", features = ["derive"] }
+
+# pinned to prevent running over Rust 1.69
+clap = { version = "<4.4", features = ["derive"] }
+clap_lex = "<0.5.1"
+anstyle = "<1.0.3"
+anstyle-parse = "<0.2.2"
[[bin]]
name = "systemd-shim"