From 48eab6203bf618ef363ad56418a7e8a78290e29b Mon Sep 17 00:00:00 2001 From: Manuel Bluhm Date: Wed, 1 May 2024 15:49:57 +0400 Subject: [PATCH] Minor fixes addressing comments Signed-off-by: Manuel Bluhm --- modules/desktop/graphics/hardware.nix | 49 ++++++++++++++++--- 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-installer/flake-module.nix | 2 +- targets/lenovo-x1/everything.nix | 1 + targets/lenovo-x1/guivmExtraModules.nix | 6 +-- 9 files changed, 54 insertions(+), 23 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 63eb4a30e..7b2897695 100644 --- a/modules/desktop/graphics/hardware.nix +++ b/modules/desktop/graphics/hardware.nix @@ -1,13 +1,50 @@ # Copyright 2024 TII (SSRC) and the Ghaf contributors # SPDX-License-Identifier: Apache-2.0 {lib, ...}: -with lib; { +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 = { - networkDevice = mkOption { - type = types.anything; - default = {}; - description = '' - Network device interface for use with graphics stack. + 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 15e749c82..90ec291b2 100644 --- a/modules/desktop/graphics/waybar.config.nix +++ b/modules/desktop/graphics/waybar.config.nix @@ -7,14 +7,14 @@ ... }: let cfg = config.ghaf.graphics.labwc; - inherit (config.ghaf.graphics.hardware) networkDevice; + inherit (config.ghaf.graphics.hardware) networkDevices; inherit (import ../../../lib/icons.nix {inherit pkgs lib;}) svgToPNG; launchpad-icon = svgToPNG "launchpad" ../../../assets/icons/svg/launchpad.svg "38x38"; admin-icon = svgToPNG "admin" ../../../assets/icons/svg/admin-cog.svg "24x24"; ghaf-icon = svgToPNG "ghaf-white" ../../../assets/icons/svg/ghaf-white.svg "24x24"; - 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 af90c4e2a..3cdddd799 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 87c9ae173..9fbea6e6c 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 c09c4496b..8b6c82413 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-installer/flake-module.nix b/targets/lenovo-x1-installer/flake-module.nix index c618b943d..f7308ca39 100644 --- a/targets/lenovo-x1-installer/flake-module.nix +++ b/targets/lenovo-x1-installer/flake-module.nix @@ -25,7 +25,7 @@ in { imports = [ "${toString modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" - ../../modules/common/hardware/ax88179_178a.nix + ../../modules/hardware/x86_64-generic/modules/ax88179_178a.nix ]; ghaf.hardware.ax88179_178a.enable = true; diff --git a/targets/lenovo-x1/everything.nix b/targets/lenovo-x1/everything.nix index ecd501669..046cf3455 100644 --- a/targets/lenovo-x1/everything.nix +++ b/targets/lenovo-x1/everything.nix @@ -40,6 +40,7 @@ }: let powerControl = pkgs.callPackage ../../packages/powercontrol {}; in { + security.polkit.extraConfig = powerControl.polkitExtraConfig; time.timeZone = "Asia/Dubai"; # Enable pulseaudio support for host as a service diff --git a/targets/lenovo-x1/guivmExtraModules.nix b/targets/lenovo-x1/guivmExtraModules.nix index f249173f0..d046fb643 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"; @@ -151,7 +151,7 @@ microvm.qemu = { extraArgs = - [ + [ # Lenovo X1 Lid button "-device" "button" @@ -165,7 +165,7 @@ "-audiodev" "pa,id=pa1,server=unix:/run/pulse/native" ] - ++ lib.optionals configH.ghaf.hardware.fprint.enable configH.ghaf.hardware.fprint.qemuExtraArgs; + ++ lib.optionals configH.ghaf.hardware.fprint.enable configH.ghaf.hardware.fprint.qemuExtraArgs; }; }; in