Skip to content

Commit 232844c

Browse files
hardware: add the demo desktop
A first desktop running Ghaf. Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
1 parent 7c7f199 commit 232844c

File tree

6 files changed

+251
-1
lines changed

6 files changed

+251
-1
lines changed

modules/hardware/common/qemu.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ in
2828
config = {
2929
ghaf.qemu.guivm = optionalAttrs (hasAttr "hardware" config.ghaf) {
3030
microvm.qemu.extraArgs =
31-
[
31+
optionals (config.ghaf.hardware.definition.type == "laptop") [
3232
# Button
3333
"-device"
3434
"button"
@@ -40,6 +40,7 @@ in
4040
"acad"
4141
]
4242
++ optionals (hasAttr "yubikey" config.ghaf.hardware.usb.external.qemuExtraArgs) config.ghaf.hardware.usb.external.qemuExtraArgs.yubikey
43+
++ optionals (hasAttr "usbKBD" config.ghaf.hardware.usb.external.qemuExtraArgs) config.ghaf.hardware.usb.external.qemuExtraArgs.usbKBD
4344
++ optionals (hasAttr "fpr0" config.ghaf.hardware.usb.internal.qemuExtraArgs) config.ghaf.hardware.usb.internal.qemuExtraArgs.fpr0
4445
++ optionals config.ghaf.hardware.usb.vhotplug.enableEvdevPassthrough builtins.concatMap (n: [
4546
"-device"

modules/hardware/definition.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ in
172172
default = [ ];
173173
};
174174

175+
type = mkOption {
176+
description = "Type of hardware (laptop, desktop, server)";
177+
type = types.str;
178+
default = "laptop";
179+
};
180+
175181
host = {
176182
kernelConfig = mkOption {
177183
description = "Host kernel configuration";
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# Copyright 2024 TII (SSRC) and the Ghaf contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
{
4+
# System name
5+
name = "Demo Tower";
6+
7+
# List of system SKUs covered by this configuration
8+
skus = [ "Be Quiet mk1" ];
9+
10+
type = "desktop";
11+
12+
# Host configuration
13+
host = {
14+
kernelConfig.kernelParams = [
15+
"amd_iommu=force_isolation"
16+
"iommu=pt"
17+
"acpi_backlight=vendor"
18+
"acpi_osi=linux"
19+
"module_blacklist=i2c_nvidia_gpu,igb,iwlwifi,nouveau,nvidiafb,r8169,snd_hda_intel"
20+
];
21+
};
22+
23+
# Input devices
24+
input = {
25+
keyboard = {
26+
name = [ ];
27+
evdev = [ ];
28+
};
29+
30+
mouse = {
31+
name = [ ];
32+
evdev = [ ];
33+
};
34+
35+
touchpad = {
36+
name = [ ];
37+
evdev = [ ];
38+
};
39+
40+
misc = {
41+
name = [
42+
# "HDA NVidia HDMI/DP,pcm=3" "HDA NVidia HDMI/DP,pcm=7" "HDA NVidia HDMI/DP,pcm=8" "HDA NVidia HDMI/DP,pcm=9" "Generic USB Audio Consumer Control" "Generic USB Audio" "Power Button"
43+
];
44+
evdev = [
45+
# /dev/input/by-id/usb-Microsoft_Microsoft®_Nano_Transceiver_v2.0-event-if01 /dev/input/by-path/pci-0000:48:00.1-usb-0:1:1.1-event /dev/input/by-path/pci-0000:48:00.1-usbv2-0:1:1.1-event /dev/input/by-path/pci-0000:48:00.1-usb-0:1:1.2-event-joystick /dev/input/by-path/pci-0000:48:00.1-usbv2-0:1:1.2-event-joystick /dev/input/by-id/usb-Microsoft_Microsoft®_Nano_Transceiver_v2.0-if02-event-joystick /dev/input/by-path/pci-0000:48:00.3-usbv2-0:5:1.7-event /dev/input/by-path/pci-0000:48:00.3-usb-0:5:1.7-event /dev/input/by-id/usb-Generic_USB_Audio-event-if07 /dev/input/by-path/pci-0000:48:00.3-usb-0:5:1.7-event /dev/input/by-path/pci-0000:48:00.3-usbv2-0:5:1.7-event /dev/input/by-id/usb-Generic_USB_Audio-event-if07
46+
];
47+
};
48+
};
49+
50+
# Main disk device
51+
disks = {
52+
disk1.device = "/dev/nvme0n1";
53+
};
54+
55+
# Network devices for passthrough to netvm
56+
network = {
57+
pciDevices = [
58+
{
59+
# Network controller: Intel Corporation Wi-Fi 6 AX200 (rev 1a)
60+
name = "wlp0s5f1";
61+
path = "0000:46:00.0";
62+
vendorId = "8086";
63+
productId = "2723";
64+
# Detected kernel driver: iwlwifi
65+
# Detected kernel modules: iwlwifi
66+
}
67+
{
68+
# Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 01)
69+
name = "eth1";
70+
path = "0000:47:00.0";
71+
vendorId = "10ec";
72+
productId = "8125";
73+
# Detected kernel driver: r8169
74+
# Detected kernel modules: r8169
75+
}
76+
{
77+
# Ethernet controller [0200]: Intel Corporation I211 Gigabit Network Connection [8086:1539] (rev 03)
78+
name = "eth0";
79+
path = "0000:45:00.0";
80+
vendorId = "8086";
81+
productId = "1539";
82+
}
83+
];
84+
kernelConfig = {
85+
# Kernel modules are indicative only, please investigate with lsmod/modinfo
86+
stage1.kernelModules = [ ];
87+
stage2.kernelModules = [
88+
"iwlwifi"
89+
"r8169"
90+
];
91+
kernelParams = [ ];
92+
};
93+
};
94+
95+
# GPU devices for passthrough to guivm
96+
gpu = {
97+
pciDevices = [
98+
{
99+
# USB controller: NVIDIA Corporation TU104 USB 3.1 Host Controller (rev a1)
100+
name = "gpu0-0";
101+
path = "0000:01:00.2";
102+
vendorId = "10de";
103+
productId = "1ad8";
104+
# Detected kernel driver: xhci_hcd
105+
# Detected kernel modules: xhci_pci
106+
}
107+
{
108+
# VGA compatible controller: NVIDIA Corporation TU104GL [Quadro RTX 4000] (rev a1)
109+
name = "gpu0-1";
110+
path = "0000:01:00.0";
111+
vendorId = "10de";
112+
productId = "1eb1";
113+
# Detected kernel driver: nouveau
114+
# Detected kernel modules: nvidiafb,nouveau
115+
}
116+
{
117+
# Serial bus controller: NVIDIA Corporation TU104 USB Type-C UCSI Controller (rev a1)
118+
name = "gpu0-2";
119+
path = "0000:01:00.3";
120+
vendorId = "10de";
121+
productId = "1ad9";
122+
# Detected kernel driver: nvidia-gpu
123+
# Detected kernel modules: i2c_nvidia_gpu
124+
}
125+
{
126+
# Audio device: NVIDIA Corporation TU104 HD Audio Controller (rev a1)
127+
name = "gpu0-3";
128+
path = "0000:01:00.1";
129+
vendorId = "10de";
130+
productId = "10f8";
131+
# Detected kernel driver: snd_hda_intel
132+
# Detected kernel modules: snd_hda_intel
133+
}
134+
];
135+
kernelConfig = {
136+
# Kernel modules are indicative only, please investigate with lsmod/modinfo
137+
stage1.kernelModules = [
138+
"i2c_nvidia_gpu"
139+
"nvidiafb"
140+
"snd_hda_intel"
141+
"xhci_pci"
142+
];
143+
stage2.kernelModules = [ ];
144+
kernelParams = [
145+
"earlykms"
146+
];
147+
};
148+
};
149+
150+
# Audio device for passthrough to audiovm
151+
audio = {
152+
acpiPath = null;
153+
pciDevices = [
154+
{
155+
# Audio device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse HD Audio Controller
156+
name = "snd1";
157+
path = "0000:22:00.4";
158+
vendorId = "1022";
159+
productId = "1487";
160+
# Detected kernel driver: snd_hda_intel
161+
# Detected kernel modules: snd_hda_intel
162+
}
163+
];
164+
kernelConfig = {
165+
# Kernel modules are indicative only, please investigate with lsmod/modinfo
166+
stage1.kernelModules = [ ];
167+
stage2.kernelModules = [
168+
"snd_hda_intel"
169+
];
170+
kernelParams = [ ];
171+
};
172+
};
173+
174+
# USB devices for passthrough
175+
usb = {
176+
internal = [ ];
177+
external = [
178+
{
179+
name = "usbKBD";
180+
vendorId = "045e";
181+
productId = "0800";
182+
}
183+
]; # Add external USB devices here
184+
};
185+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2025 TII (SSRC) and the Ghaf contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
{
4+
pkgs,
5+
config,
6+
...
7+
}:
8+
{
9+
hardware = {
10+
#TODO: Should see how to add microcode updates to all systems
11+
#cpu.amd.updateMicrocode = true;
12+
13+
graphics.extraPackages = [
14+
pkgs.egl-wayland
15+
pkgs.mesa
16+
pkgs.libGL
17+
];
18+
nvidia = {
19+
modesetting.enable = true;
20+
powerManagement.enable = false;
21+
powerManagement.finegrained = false;
22+
forceFullCompositionPipeline = true;
23+
open = false;
24+
nvidiaSettings = true;
25+
# Optionally, you may need to select the appropriate driver version for your specific GPU.
26+
package = config.boot.kernelPackages.nvidiaPackages.beta; # was stable
27+
};
28+
};
29+
30+
# Load nvidia driver for Xorg and Wayland
31+
services.xserver.videoDrivers = [ "nvidia" ];
32+
33+
microvm.qemu.extraArgs = [
34+
"-drive"
35+
"file=${pkgs.OVMF.fd}/FV/OVMF_CODE.fd,if=pflash,unit=0,readonly=true"
36+
"-drive"
37+
"file=${pkgs.OVMF.fd}/FV/OVMF_VARS.fd,if=pflash,unit=1,readonly=true"
38+
];
39+
}

modules/reference/hardware/flake-module.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
ghaf.hardware.definition = import ./dell-latitude/definitions/dell-latitude-7330-71.nix;
3535
}
3636
];
37+
hardware-demo-tower-mk1.imports = [
38+
{
39+
ghaf.hardware.definition = import ./demo-tower/demo-tower.nix;
40+
ghaf.virtualization.microvm.guivm.extraModules = [
41+
(import ./demo-tower/extra-config.nix)
42+
];
43+
}
44+
];
45+
3746
hardware-lenovo-x1-carbon-gen10.imports = [
3847
{
3948
ghaf.hardware.definition = import ./lenovo-x1/definitions/x1-gen10.nix;

targets/laptop/flake-module.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ let
114114
};
115115
}
116116
]))
117+
(laptop-configuration "demo-tower-mk1" "debug" (withCommonModules [
118+
self.nixosModules.hardware-demo-tower-mk1
119+
{
120+
ghaf = {
121+
reference.profiles.mvp-user-trial.enable = true;
122+
partitioning.disko.enable = true;
123+
hardware.tpm2.enable = lib.mkForce false;
124+
};
125+
}
126+
]))
117127

118128
# Laptop Release configurations
119129
(laptop-configuration "lenovo-x1-carbon-gen10" "release" (withCommonModules [

0 commit comments

Comments
 (0)