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

Load kernel modules #524

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions modules/usbip.nix
Original file line number Diff line number Diff line change
@@ -59,5 +59,7 @@ in

targets.multi-user.wants = map (busid: "usbip-auto-attach@${busid}.service") cfg.autoAttach;
};

wsl.kernelModules = [ "vhci-hcd" ];
};
}
11 changes: 11 additions & 0 deletions modules/wsl-distro.nix
Original file line number Diff line number Diff line change
@@ -10,6 +10,14 @@ in
options.wsl = with types; {
enable = mkEnableOption "support for running NixOS as a WSL distribution";
useWindowsDriver = mkEnableOption "OpenGL driver from the Windows host";
kernelModules = mkOption {
type = listOf str;
default = [ ];
description = ''
The set of kernel modules to be loaded in the second stage of
the boot process via systemd-modules-load.service.
'';
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we reuse boot.kernelModules here?

Copy link
Contributor Author

@terlar terlar Aug 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is gated behind boot.kernel.enable which we don't want to enable.

Another option is to have something like a boolean wsl.loadKernelModules. That will write the file with the value based on boot.kernelModules. What do you prefer?

binShPkg = mkOption {
type = package;
internal = true;
@@ -109,6 +117,9 @@ in
(mkIf config.wsl.wslConf.network.generateResolvConf {
"resolv.conf".enable = false;
})
(mkIf (cfg.kernelModules != [ ]) {
"modules-load.d/nixos.conf".text = concatStringsSep "\n" cfg.kernelModules;
})
];
};


Unchanged files with check annotations Beta

out ulong defaultEnvironmentVariableCount
);
byte** envv;

Check notice on line 28 in Launcher/Launcher/src/WSL/WslGetDistributionConfiguration.cs

GitHub Actions / Checks 📋 / Check .NET 📋

InlineOutVariableDeclaration

Inline 'out' variable declaration
ulong envc;

Check notice on line 29 in Launcher/Launcher/src/WSL/WslGetDistributionConfiguration.cs

GitHub Actions / Checks 📋 / Check .NET 📋

InlineOutVariableDeclaration

Inline 'out' variable declaration
CheckResult(
WslGetDistributionConfiguration(
namespace Launcher.WSL;
public static partial class WslApiLoader {
public static void WslLaunch(

Check notice on line 10 in Launcher/Launcher/src/WSL/WslLaunch.cs

GitHub Actions / Checks 📋 / Check .NET 📋

MemberCanBePrivate.Global

Method 'WslLaunch' can be made private
string distributionName,
string? command,
bool useCurrentWorkingDirectory,
string distributionName,
string command,
bool useCurrentWorkingDirectory,
out uint exitCode,

Check notice on line 24 in Launcher/Launcher/src/WSL/WslLaunchGetOutput.cs

GitHub Actions / Checks 📋 / Check .NET 📋

OutParameterValueIsAlwaysDiscarded.Global

Parameter 'exitCode' output value is always discarded
bool noStderr = false
) {
using SafeFileHandle realStdin = new(GetStdHandle(STD_HANDLE.STD_INPUT_HANDLE), false);
<data name="Error_NotInstalled" xml:space="preserve">
<value>{0} ist nicht installiert!</value>
</data>
<data name="Version_Launcher" xml:space="preserve">

Check notice on line 76 in Launcher/Launcher/src/i18n/Translations.de.resx

GitHub Actions / Checks 📋 / Check .NET 📋

OverriddenWithSameValue

Resource is overridden with identical value
<value>Launcher: {0}</value>
</data>
<data name="Version_Module" xml:space="preserve">
[Flags]
[SuppressMessage("Naming", "CA1711")] // Flags suffix is appropriate
public enum WslDistributionFlags {
None = 0x0,

Check notice on line 9 in Launcher/Launcher/src/WSL/WslDistributionFlags.cs

GitHub Actions / Checks 📋 / Check .NET 📋

UnusedMember.Global

Enum member 'None' is never used
EnableInterop = 0x1,
AppendNtPath = 0x2,
EnableDriveMounting = 0x4
}
public const WslDistributionFlags WslDistributionFlagsValid =

Check notice on line 15 in Launcher/Launcher/src/WSL/WslDistributionFlags.cs

GitHub Actions / Checks 📋 / Check .NET 📋

UnusedMember.Global

Constant 'WslDistributionFlagsValid' is never used
WslDistributionFlags.EnableInterop |
WslDistributionFlags.AppendNtPath |
WslDistributionFlags.EnableDriveMounting;
public const WslDistributionFlags WslDistributionFlagsDefault =

Check notice on line 20 in Launcher/Launcher/src/WSL/WslDistributionFlags.cs

GitHub Actions / Checks 📋 / Check .NET 📋

UnusedMember.Global

Constant 'WslDistributionFlagsDefault' is never used
WslDistributionFlags.EnableInterop |
WslDistributionFlags.AppendNtPath |
WslDistributionFlags.EnableDriveMounting;
namespace Launcher;
public static class ExceptionContext {
public static void AddContext(this Exception e, string context) => throw new ContextualizedException(context, e);

Check notice on line 6 in Launcher/Launcher/src/ExceptionContext.cs

GitHub Actions / Checks 📋 / Check .NET 📋

UnusedMember.Global

Method 'AddContext' is never used
public static void AddIfThrown(Action action, string context) {
try {
namespace Launcher.WSL;
public static partial class WslApiLoader {
public static void WslConfigureDistribution(

Check notice on line 8 in Launcher/Launcher/src/WSL/WslConfigureDistribution.cs

GitHub Actions / Checks 📋 / Check .NET 📋

UnusedMember.Global

Method 'WslConfigureDistribution' is never used
string distributionName,
ulong defaultUid,
WslDistributionFlags wslDistributionFlags