Skip to content

Commit

Permalink
Refactor USB network card patch a bit
Browse files Browse the repository at this point in the history
* Rename the module to ax88179_178a, which is the kernel module name.
* Enable manually based on option instead of condition based on
  config.boot.kernelPackages.kernel.version, which started to cause
  infinite recursion when evaluating against nixos-unstable.
* Enable manually only for platforms knwon having affected 6.1.x kernel.

Signed-off-by: Mika Tammi <mika.tammi@unikie.com>
  • Loading branch information
Mika Tammi committed Apr 10, 2024
1 parent ae77a61 commit 8800210
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
29 changes: 29 additions & 0 deletions modules/common/hardware/ax88179_178a.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
#
# Fix for ax88179_178a USB network card kernel driver MAC-address issue.
{
lib,
pkgs,
config,
...
}: let
cfg = config.ghaf.hardware.ax88179_178a;
in {
options.ghaf.hardware.ax88179_178a = {
enable = lib.mkEnableOption "fix for ax88179_178a USB network card kernel driver MAC-address";
};

config = lib.mkIf cfg.enable {
boot.kernelPatches = [
# Fix MAC-address randomized on USB network cards because of kernel bug.
# This specifically affects network cards used in testing.
{
patch = pkgs.fetchpatch2 {
url = "https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/patch/?id=2e91bb99b9d4f756e92e83c4453f894dda220f09";
hash = "sha256-fX7yBsXW1oFt1Nfns42oZnCXf36qehXijvCNEmqBGsE=";
};
}
];
};
}
2 changes: 1 addition & 1 deletion modules/common/hardware/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
./x86_64-generic
./definition.nix

./usb-network-kernel-patch.nix
./ax88179_178a.nix
];
}
24 changes: 0 additions & 24 deletions modules/common/hardware/usb-network-kernel-patch.nix

This file was deleted.

1 change: 1 addition & 0 deletions targets/generic-x86_64/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
{
ghaf = {
hardware.x86_64.common.enable = true;
hardware.ax88179_178a.enable = true;

virtualization.microvm-host.enable = true;
virtualization.microvm-host.networkSupport = true;
Expand Down
3 changes: 3 additions & 0 deletions targets/lenovo-x1-installer/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
in {
imports = [
"${toString modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
../../modules/common/hardware/ax88179_178a.nix
];

ghaf.hardware.ax88179_178a.enable = true;

# SSH key to installer for test automation.
users.users.nixos.openssh.authorizedKeys.keys = lib.mkIf (variant == "debug") [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAolaKCuIUBQSBFGFZI1taNX+JTAr8edqUts7A6k2Kv7"
Expand Down
1 change: 1 addition & 0 deletions targets/lenovo-x1/everything.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
host.kernel.hardening.hypervisor.enable = false;

hardware.x86_64.common.enable = true;
hardware.ax88179_178a.enable = true;

security.tpm2.enable = true;

Expand Down

0 comments on commit 8800210

Please sign in to comment.