-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite hardware definition into module and basic fingerprint support
Signed-off-by: Manuel Bluhm <manuel@ssrc.tii.ae>
- Loading branch information
Showing
39 changed files
with
206 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ | |
./gnome.nix | ||
./window-manager.nix | ||
./boot.nix | ||
./hardware.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ | ||
config, | ||
lib, | ||
... | ||
}: | ||
with lib; { | ||
options.ghaf.graphics.hardware = { | ||
networkDevice = mkOption { | ||
type = types.anything; | ||
default = {}; | ||
description = '' | ||
Network device interface for use with graphics stack. | ||
''; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
_: { | ||
flake.nixosModules = { | ||
hw-lenovo-x1.imports = [ | ||
./definition.nix | ||
./x86_64-generic | ||
./lenovo-x1 | ||
]; | ||
hw-x86_64-generic.imports = [ | ||
./definition.nix | ||
./x86_64-generic | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
{ | ||
config, | ||
lib, | ||
... | ||
}: let | ||
hwDefinition = import (./. + "/x1-${config.ghaf.hardware.generation}.nix"); | ||
in { | ||
imports = [ | ||
../../definition.nix | ||
]; | ||
|
||
options.ghaf.hardware.generation = lib.mkOption { | ||
description = "Generation of the hardware configuration"; | ||
type = lib.types.str; | ||
default = "gen11"; | ||
}; | ||
|
||
config = { | ||
ghaf.hardware.definition = { | ||
inherit (hwDefinition) mouse; | ||
inherit (hwDefinition) touchpad; | ||
inherit (hwDefinition) disks; | ||
inherit (hwDefinition) network; | ||
inherit (hwDefinition) gpu; | ||
|
||
virtioInputHostEvdevs = [ | ||
# Lenovo X1 touchpad and keyboard | ||
"/dev/input/by-path/platform-i8042-serio-0-event-kbd" | ||
"/dev/mouse" | ||
"/dev/touchpad" | ||
# Lenovo X1 trackpoint (red button/joystick) | ||
"/dev/input/by-path/platform-i8042-serio-1-event-mouse" | ||
]; | ||
}; | ||
|
||
disko.devices.disk = hwDefinition.disks; | ||
|
||
# Notes: | ||
# 1. This assembles udev rules for different hw configurations (i.e., different mice/touchpads) by adding | ||
# all of them to the configuration. This was chosen for simplicity to not have to provide hw identifier at build, | ||
# but is not ideal and should be changed. | ||
# 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 '' | ||
# Laptop keyboard | ||
SUBSYSTEM=="input", ATTRS{name}=="AT Translated Set 2 keyboard", GROUP="kvm" | ||
# Laptop TrackPoint | ||
SUBSYSTEM=="input", ATTRS{name}=="TPPS/2 Elan TrackPoint", GROUP="kvm" | ||
# Lenovo X1 integrated webcam | ||
KERNEL=="3-8", SUBSYSTEM=="usb", ATTR{busnum}=="3", ATTR{devnum}=="3", GROUP="kvm" | ||
# 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)} | ||
''; | ||
}; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ | ||
config, | ||
lib, | ||
pkgs, | ||
... | ||
}: let | ||
cfg = config.ghaf.hardware.fprint; | ||
in | ||
with lib; { | ||
options.ghaf.hardware.fprint = { | ||
enable = mkEnableOption "Enable fingerprint reader support"; | ||
qemuExtraArgs = mkOption { | ||
type = types.listOf types.str; | ||
default = []; | ||
description = '' | ||
Extra arguments to pass to Qemu when enabling the fingerprint reader. | ||
This is useful for passing USB device information to Qemu. | ||
''; | ||
}; | ||
extraConfigurations = mkOption { | ||
type = types.attrsOf types.anything; | ||
default = {}; | ||
description = '' | ||
Extra configurations to enable when enabling the fingerprint reader. | ||
This is useful for enabling services and packages related to the fingerprint reader. | ||
''; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
ghaf.hardware.fprint = { | ||
qemuExtraArgs = [ | ||
# Fingerprint reader | ||
"-device" | ||
"qemu-xhci" | ||
"-device" | ||
"usb-host,hostbus=3,hostport=6" | ||
]; | ||
|
||
extraConfigurations = { | ||
# Enable services and packages for fingerprint reader | ||
ghaf.systemd.withPolkit = true; | ||
security.polkit.enable = true; | ||
services.fprintd.enable = true; | ||
environment.systemPackages = with pkgs; [fprintd]; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,7 @@ | |
./kernel/hardening.nix | ||
./kernel/host | ||
./kernel/host/pkvm | ||
./x86_64-linux.nix | ||
./modules/tpm2.nix | ||
]; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.