From 56a9e309758c909b1b539e54ce797d9ddcd04af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 9 Dec 2022 15:54:16 +0100 Subject: [PATCH] Use upstream settings instead of workarounds to disable unsupported settings Closes #149 --- modules/wsl-distro.nix | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/modules/wsl-distro.nix b/modules/wsl-distro.nix index 0316c773..41859694 100644 --- a/modules/wsl-distro.nix +++ b/modules/wsl-distro.nix @@ -37,20 +37,20 @@ with lib; { mkIf cfg.enable ( mkMerge [ { - # We don't need a boot loader - boot.loader.grub.enable = false; - system.build.installBootLoader = "${pkgs.coreutils}/bin/true"; - boot.initrd.enable = false; - system.build.initialRamdisk = pkgs.runCommand "fake-initrd" { } '' - mkdir $out - touch $out/${config.system.boot.loader.initrdFile} - ''; - system.build.initialRamdiskSecretAppender = pkgs.writeShellScriptBin "append-initrd-secrets" ""; + # WSL uses its own kernel and boot loader + boot = { + initrd.enable = false; + kernel.enable = false; + loader.grub.enable = false; + modprobeConfig.enable = false; + }; + + # WSL does not support virtual consoles + console.enable = false; hardware.opengl.enable = true; # Enable GPU acceleration environment = { - # Only set the options if the files are managed by WSL etc = mkMerge [ (mkIf config.wsl.wslConf.network.generateHosts { @@ -69,6 +69,7 @@ with lib; { ]; }; + # dhcp is handled by windows networking.dhcpcd.enable = false; users.users.${cfg.defaultUser} = { @@ -102,20 +103,16 @@ with lib; { ''; }; + # no udev devices can be attached + services.udev.enable = lib.mkDefault false; + systemd = { # Disable systemd units that don't make sense on WSL services = { - # no virtual console to switch to - "serial-getty@ttyS0".enable = false; - "serial-getty@hvc0".enable = false; - "getty@tty1".enable = false; - "autovt@".enable = false; firewall.enable = false; - systemd-resolved.enable = false; + systemd-resolved.enable = lib.mkDefault false; # system clock cannot be changed systemd-timesyncd.enable = false; - # no udev devices can be attached - systemd-udevd.enable = false; }; # Don't allow emergency mode, because we don't have a console.