diff options
| author | K900 <me@0upti.me> | 2022-03-26 17:02:21 +0300 |
|---|---|---|
| committer | K900 <me@0upti.me> | 2022-03-30 19:19:56 +0300 |
| commit | d7cf4b345ac23661669d25e79fb117149f7c5b5a (patch) | |
| tree | 10e0697d542408848fc24349362df1c17614db93 /modules | |
| parent | 8d7840da6bc2ffbcec49fd86fae24f2372e05c2c (diff) | |
Allow disabling and customizing WSL-to-Windows interop
- add an option to disable interop entirely
- add an option to include Windows %PATH% in WSL $PATH
- register interop through systemd-binfmt
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/wsl-distro.nix | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/modules/wsl-distro.nix b/modules/wsl-distro.nix index c2eb550..a2d7145 100644 --- a/modules/wsl-distro.nix +++ b/modules/wsl-distro.nix @@ -28,6 +28,20 @@ with builtins; with lib; type = attrsOf (attrsOf coercedToStr); description = "Entries that are added to /etc/wsl.conf"; }; + + interop = { + register = mkOption { + type = bool; + default = true; + description = "Explicitly register the binfmt_misc handler for Windows executables"; + }; + + includePath = mkOption { + type = bool; + default = true; + description = "Include Windows PATH in WSL PATH"; + }; + }; }; config = @@ -47,12 +61,22 @@ with builtins; with lib; }; # WSL is closer to a container than anything else - boot.isContainer = true; + boot = { + isContainer = true; + + binfmt.registrations = mkIf cfg.interop.register { + WSLInterop = { + magicOrExtension = "MZ"; + interpreter = "/init"; + fixBinary = true; + }; + }; + }; environment.noXlibs = lib.mkForce false; # override xlibs not being installed (due to isContainer) to enable the use of GUI apps environment = { # Include Windows %PATH% in Linux $PATH. - extraInit = ''PATH="$PATH:$WSLPATH"''; + extraInit = mkIf cfg.interop.includePath ''PATH="$PATH:$WSLPATH"''; etc = { "wsl.conf".text = generators.toINI { } cfg.wslConf; |
