2024-04-18 21:16:40 +02:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.grimmShared;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = with cfg; lib.mkIf (enable && laptop_hardware.enable) {
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
lm_sensors
|
|
|
|
lshw
|
|
|
|
pciutils
|
|
|
|
usbutils
|
2024-04-30 12:32:03 +02:00
|
|
|
opentabletdriver
|
2024-04-26 10:25:17 +02:00
|
|
|
ddcutil
|
|
|
|
] ++ lib.optionals graphical [
|
|
|
|
ddcui
|
2024-04-18 21:16:40 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
hardware.i2c.enable = true;
|
2024-04-28 19:43:56 +02:00
|
|
|
services.libinput.enable = true;
|
2024-04-30 12:32:03 +02:00
|
|
|
hardware.opentabletdriver.enable = true;
|
2024-04-30 22:04:17 +02:00
|
|
|
services.udisks2.enable = true;
|
2024-04-26 10:25:17 +02:00
|
|
|
|
|
|
|
services.udev.extraRules = ''
|
|
|
|
SUBSYSTEM=="i2c-dev", ACTION=="add",\
|
|
|
|
ATTR{name}=="NVIDIA i2c adapter*",\
|
|
|
|
TAG+="ddcci",\
|
|
|
|
TAG+="systemd",\
|
|
|
|
ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service"
|
|
|
|
'';
|
|
|
|
|
|
|
|
systemd.services."ddcci@" = {
|
|
|
|
scriptArgs = "%i";
|
|
|
|
script = ''
|
|
|
|
sleep 20
|
|
|
|
echo Trying to attach ddcci to $1
|
|
|
|
i=0
|
|
|
|
id=$(echo $1 | cut -d "-" -f 2)
|
|
|
|
if ${pkgs.ddcutil}/bin/ddcutil getvcp 10 -b $id; then
|
|
|
|
echo ddcci 0x37 > /sys/bus/i2c/devices/$1/new_device
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
};
|
|
|
|
|
2024-04-18 21:16:40 +02:00
|
|
|
boot = {
|
|
|
|
kernelParams = [
|
|
|
|
"splash"
|
|
|
|
"quiet"
|
|
|
|
"intel_iommu=on"
|
|
|
|
"iommu=force"
|
|
|
|
"pcie_acs_override=downstream"
|
|
|
|
"mmio_stale_data=full,nosmt"
|
|
|
|
"pcie_aspm=off"
|
|
|
|
]; # "vfio-pci.ids=10de:1aeb,10de:2191,10de:1aed,10de:1aec" ];
|
2024-04-30 12:32:03 +02:00
|
|
|
initrd.availableKernelModules = [
|
|
|
|
"xhci_pci"
|
|
|
|
"ahci"
|
|
|
|
"nvme"
|
|
|
|
"usbhid"
|
|
|
|
"usb_storage"
|
|
|
|
"sd_mod"
|
|
|
|
];
|
|
|
|
loader.systemd-boot.enable = true;
|
2024-04-26 10:25:17 +02:00
|
|
|
extraModulePackages = [
|
|
|
|
(config.boot.kernelPackages.ddcci-driver.overrideAttrs
|
|
|
|
(old: {
|
|
|
|
patches = [
|
|
|
|
(pkgs.fetchpatch {
|
|
|
|
url = "https://gitlab.com/Sweenu/ddcci-driver-linux/-/commit/7f851f5fb8fbcd7b3a93aaedff90b27124e17a7e.patch";
|
|
|
|
hash = "sha256-Y1ktYaJTd9DtT/mwDqtjt/YasW9cVm0wI43wsQhl7Bg=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}))
|
|
|
|
];
|
|
|
|
kernelModules = [
|
|
|
|
"kvm-intel"
|
|
|
|
"vfio_pci"
|
|
|
|
"vfio_iommu_type1"
|
|
|
|
"vfio"
|
|
|
|
"ddcci_backlight"
|
|
|
|
"i2c-dev"
|
|
|
|
];
|
|
|
|
# blacklistedKernelModules = [ "i2c_nvidia_gpu" ];
|
2024-04-18 21:16:40 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
options.grimmShared.laptop_hardware = {
|
|
|
|
enable = lib.mkEnableOption "grimm-laptop";
|
|
|
|
};
|
|
|
|
}
|
2024-04-26 21:36:24 +02:00
|
|
|
|