Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make resolve settings easier overwritable #103

Merged
merged 4 commits into from
Jul 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions modules/wsl-distro.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
};
};

Expand Down Expand Up @@ -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");
};
}