diff --git a/modules/wsl-distro.nix b/modules/wsl-distro.nix index bb7ff6a5..b2bc8a0e 100644 --- a/modules/wsl-distro.nix +++ b/modules/wsl-distro.nix @@ -25,7 +25,7 @@ with builtins; with lib; }; startMenuLaunchers = mkEnableOption "shortcuts for GUI applications in the windows start menu"; wslConf = mkOption { - type = attrsOf (attrsOf coercedToStr); + type = attrsOf (attrsOf (oneOf [ string int bool ])); description = "Entries that are added to /etc/wsl.conf"; }; @@ -72,6 +72,10 @@ with builtins; with lib; root = "${cfg.automountPath}/"; options = cfg.automountOptions; }; + network = { + generateResolvConf = mkDefault true; + generateHosts = mkDefault true; + }; }; # WSL is closer to a container than anything else @@ -126,8 +130,8 @@ with builtins; with lib; "wsl.conf".text = generators.toINI { } cfg.wslConf; # DNS settings are managed by WSL - hosts.enable = false; - "resolv.conf".enable = false; + hosts.enable = !config.wsl.wslConf.network.generateHosts; + "resolv.conf".enable = !config.wsl.wslConf.network.generateResolvConf; }; }; @@ -169,10 +173,12 @@ with builtins; with lib; systemd.services."autovt@".enable = false; systemd.services.firewall.enable = false; - systemd.services.systemd-resolved.enable = false; + systemd.services.systemd-resolved.enable = mkDefault false; systemd.services.systemd-udevd.enable = false; # Don't allow emergency mode, because we don't have a console. systemd.enableEmergencyMode = false; + + warnings = (optional (config.systemd.services.systemd-resolved.enable && config.wsl.wslConf.network.generateResolvConf) "systemd-resolved is enabled, but resolv.conf is managed by WSL"); }; }