-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
interop.nix
43 lines (36 loc) · 1.12 KB
/
interop.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ lib, config, ... }:
with builtins; with lib;
{
options.wsl.interop = with types; {
register = mkOption {
type = bool;
default = false; # Use the existing registration by default
description = "Explicitly register the binfmt_misc handler for Windows executables";
};
includePath = mkOption {
type = bool;
default = true;
description = "Include Windows PATH in WSL PATH";
};
};
config =
let
cfg = config.wsl.interop;
in
mkIf config.wsl.enable {
boot.binfmt.registrations = mkIf cfg.register {
WSLInterop = {
magicOrExtension = "MZ";
fixBinary = true;
wrapInterpreterInShell = false;
interpreter = "/init";
preserveArgvZero = true;
};
};
warnings =
let
registrations = config.boot.binfmt.registrations;
in
optional (!(registrations ? WSLInterop) && (length (attrNames config.boot.binfmt.registrations)) != 0) "Having any binfmt registrations without re-registering WSLInterop (wsl.interop.register) will break running .exe files from WSL2";
};
}