grimm-nixos-laptop/common/hardware/laptop.nix
2024-11-26 19:20:10 +01:00

94 lines
2.2 KiB
Nix

{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable laptop_hardware graphical;
in
{
config = lib.mkIf (enable && laptop_hardware.enable) {
environment.systemPackages =
with pkgs;
[
lm_sensors
lshw
pciutils
usbutils
ddcutil
python312Packages.py-cpuinfo
(writeShellScriptBin "lsiommu" ./lsiommu)
]
++ lib.optionals graphical [
opentabletdriver
ddcui
wootility
];
services.udev.packages = with pkgs; [ yubikey-personalization ];
boot.bcache.enable = false;
# hardware.i2c.enable = true;
services.libinput.enable = true;
hardware.opentabletdriver.enable = true;
systemd.user.services.opentabletdriver.after = [ "local-fs.target" ];
services.udisks2.enable = true;
#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 ${lib.getExe' pkgs.ddcutil "ddcutil"} getvcp 10 -b $id; then
# echo ddcci 0x37 > /sys/bus/i2c/devices/$1/new_device
# fi
# '';
# serviceConfig.Type = "oneshot";
#};
systemd.enableCgroupAccounting = true;
# systemd.enableUnifiedCgroupHierarchy = false;
boot = {
kernelParams = [
"intel_iommu=on"
"nohibernate"
"pcie_aspm=off"
];
loader.efi.canTouchEfiVariables = true;
initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"nvme"
"usbhid"
"usb_storage"
"sd_mod"
];
# initrd.systemd.enable = true;
loader.systemd-boot.enable = true;
# extraModulePackages = [ config.boot.kernelPackages.ddcci-driver ];
kernelModules = [
# "ddcci_backlight"
# "i2c-dev"
"ec_sys"
];
};
};
options.grimmShared.laptop_hardware = {
enable = lib.mkEnableOption "grimm-laptop";
};
}