From 6fb31b1c686f6b79baec5b78508014dada62d16b Mon Sep 17 00:00:00 2001 From: Manuel Bluhm Date: Mon, 29 Apr 2024 15:04:25 +0400 Subject: [PATCH] Minor fixes addressing comments Signed-off-by: Manuel Bluhm --- modules/desktop/graphics/hardware.nix | 58 +++++++++++++++---- modules/desktop/graphics/waybar.config.nix | 4 +- modules/hardware/lenovo-x1/default.nix | 1 - .../lenovo-x1/definitions/default.nix | 13 +---- modules/hardware/x86_64-generic/default.nix | 1 + .../modules}/ax88179_178a.nix | 0 targets/lenovo-x1/guivmExtraModules.nix | 2 +- 7 files changed, 55 insertions(+), 24 deletions(-) rename modules/hardware/{ => x86_64-generic/modules}/ax88179_178a.nix (100%) diff --git a/modules/desktop/graphics/hardware.nix b/modules/desktop/graphics/hardware.nix index 63eb4a30ec..af78709f6d 100644 --- a/modules/desktop/graphics/hardware.nix +++ b/modules/desktop/graphics/hardware.nix @@ -1,14 +1,52 @@ # Copyright 2024 TII (SSRC) and the Ghaf contributors # SPDX-License-Identifier: Apache-2.0 {lib, ...}: -with lib; { - options.ghaf.graphics.hardware = { - networkDevice = mkOption { - type = types.anything; - default = {}; - description = '' - Network device interface for use with graphics stack. - ''; +with lib; + let + pciDevSubmodule = types.submodule { + options = { + path = mkOption { + type = types.str; + description = '' + PCI device path + ''; + }; + vendorId = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + PCI Vendor ID (optional) + ''; + }; + productId = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + PCI Product ID (optional) + ''; + }; + name = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + PCI device name (optional) + ''; + }; + }; }; - }; -} + in { + options.ghaf.graphics.hardware = { + networkDevices = mkOption { + description = "Network PCI Devices"; + type = types.listOf pciDevSubmodule; + default = []; + example = literalExpression '' + [{ + path = "0000:00:14.3"; + vendorId = "8086"; + productId = "51f1"; + }] + ''; + }; + }; + } diff --git a/modules/desktop/graphics/waybar.config.nix b/modules/desktop/graphics/waybar.config.nix index ce8935e7a7..fe788adf42 100644 --- a/modules/desktop/graphics/waybar.config.nix +++ b/modules/desktop/graphics/waybar.config.nix @@ -7,7 +7,7 @@ ... }: let cfg = config.ghaf.graphics.labwc; - inherit (config.ghaf.graphics.hardware) networkDevice; + inherit (config.ghaf.graphics.hardware) networkDevices; ghaf-icon = pkgs.runCommand "ghaf-icon-24x24" {} '' mkdir -p $out/share/icons/hicolor/24x24/apps @@ -17,7 +17,7 @@ $out/share/icons/hicolor/24x24/apps/ghaf-icon-24x24.png ''; - wifiDevice = lib.lists.findFirst (d: d.name != null) null networkDevice; + wifiDevice = lib.lists.findFirst (d: d.name != null) null networkDevices; wifi-signal-strength = pkgs.callPackage ../../../packages/wifi-signal-strength {wifiDevice = wifiDevice.name;}; ghaf-launcher = pkgs.callPackage ./ghaf-launcher.nix {inherit config pkgs;}; timeZone = diff --git a/modules/hardware/lenovo-x1/default.nix b/modules/hardware/lenovo-x1/default.nix index af90c4e2a1..3cdddd799d 100644 --- a/modules/hardware/lenovo-x1/default.nix +++ b/modules/hardware/lenovo-x1/default.nix @@ -3,7 +3,6 @@ { imports = [ ./definitions - ./ax88179_178a.nix ./modules/fprint.nix ]; } diff --git a/modules/hardware/lenovo-x1/definitions/default.nix b/modules/hardware/lenovo-x1/definitions/default.nix index 87c9ae173d..9fbea6e6cf 100644 --- a/modules/hardware/lenovo-x1/definitions/default.nix +++ b/modules/hardware/lenovo-x1/definitions/default.nix @@ -45,14 +45,7 @@ in { # 2. USB camera "passthrough" is handled by qemu and thus available on host. If peripheral VM is implemented, # the entire host controller should be passthrough'd using the PCI bus (14.0). In x1, bluetooth and fingerprint # reader are on this bus. - services.udev.extraRules = let - mapMouseRules = - builtins.map (d: '' SUBSYSTEM=="input", ATTRS{name}=="${d}", KERNEL=="event*", GROUP="kvm", SYMLINK+="mouse" - ''); - mapTouchpadRules = - builtins.map (d: '' SUBSYSTEM=="input", ATTRS{name}=="${d}", KERNEL=="event*", GROUP="kvm", SYMLINK+="touchpad" - ''); - in '' + services.udev.extraRules = '' # Laptop keyboard SUBSYSTEM=="input", ATTRS{name}=="AT Translated Set 2 keyboard", GROUP="kvm" # Laptop TrackPoint @@ -62,8 +55,8 @@ in { # Lenovo X1 integrated fingerprint reader KERNEL=="3-6", SUBSYSTEM=="usb", ATTR{busnum}=="3", ATTR{devnum}=="2", GROUP="kvm" # Mouse and Touchpad - ${lib.strings.concatStrings (mapMouseRules hwDefinition.mouse)} - ${lib.strings.concatStrings (mapTouchpadRules hwDefinition.touchpad)} + ${lib.strings.concatMapStringsSep "\n" (d: ''SUBSYSTEM=="input", ATTRS{name}=="${d}", KERNEL=="event*", GROUP="kvm", SYMLINK+="mouse"'') hwDefinition.mouse} + ${lib.strings.concatMapStringsSep "\n" (d: ''SUBSYSTEM=="input", ATTRS{name}=="${d}", KERNEL=="event*", GROUP="kvm", SYMLINK+="touchpad"'') hwDefinition.touchpad} ''; }; } diff --git a/modules/hardware/x86_64-generic/default.nix b/modules/hardware/x86_64-generic/default.nix index c09c4496b6..8b6c824135 100644 --- a/modules/hardware/x86_64-generic/default.nix +++ b/modules/hardware/x86_64-generic/default.nix @@ -8,5 +8,6 @@ ./kernel/host/pkvm ./x86_64-linux.nix ./modules/tpm2.nix + ./modules/ax88179_178a.nix ]; } diff --git a/modules/hardware/ax88179_178a.nix b/modules/hardware/x86_64-generic/modules/ax88179_178a.nix similarity index 100% rename from modules/hardware/ax88179_178a.nix rename to modules/hardware/x86_64-generic/modules/ax88179_178a.nix diff --git a/targets/lenovo-x1/guivmExtraModules.nix b/targets/lenovo-x1/guivmExtraModules.nix index a52f3c42e4..a87fef9629 100644 --- a/targets/lenovo-x1/guivmExtraModules.nix +++ b/targets/lenovo-x1/guivmExtraModules.nix @@ -37,7 +37,7 @@ }; guivmExtraConfigurations = { - ghaf.graphics.hardware.networkDevice = configH.ghaf.hardware.definition.network.pciDevices; + ghaf.graphics.hardware.networkDevices = configH.ghaf.hardware.definition.network.pciDevices; ghaf.profiles.graphics.compositor = "labwc"; ghaf.graphics.launchers = let hostAddress = "192.168.101.2";