Skip to content

Commit 0c52cbe

Browse files
committed
interop: enable preserveArgvZero
Fixes interop with latest WSL versions
1 parent 80c18db commit 0c52cbe

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

modules/wsl-distro.nix

+15-1
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,22 @@ with builtins; with lib;
6767
binfmt.registrations = mkIf cfg.interop.register {
6868
WSLInterop = {
6969
magicOrExtension = "MZ";
70-
interpreter = "/init";
70+
71+
# FIXME: temporary hack for https://github.com/nix-community/NixOS-WSL/pull/84
72+
interpreter = pkgs.writeShellScript "nixos-wsl-binfmt-hack" ''
73+
/init /nixos-wsl-does-not-exist.exe
74+
if [ $? -eq 1 ]; then
75+
# new style /init wants preserve-argv0
76+
exec /init $@
77+
else
78+
# old style /init does not
79+
shift
80+
exec /init $@
81+
fi
82+
'';
83+
7184
fixBinary = true;
85+
preserveArgvZero = true;
7286
};
7387
};
7488
};

0 commit comments

Comments
 (0)