grimm-nixos-laptop/common/hardware/laptop.nix

86 lines
1.9 KiB
Nix
Raw Normal View History

2024-05-07 23:31:41 +02:00
{
pkgs,
config,
lib,
...
}:
2024-04-18 21:16:40 +02:00
let
2024-05-11 22:55:59 +02:00
inherit (config.grimmShared) enable laptop_hardware graphical;
2024-04-18 21:16:40 +02:00
in
{
2024-05-11 22:55:59 +02:00
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
];
2024-04-26 10:25:17 +02:00
2024-06-13 22:56:30 +02:00
services.udev.packages = with pkgs; [
yubikey-personalization
];
2024-05-11 22:55:59 +02:00
hardware.i2c.enable = true;
services.libinput.enable = true;
hardware.opentabletdriver.enable = true;
services.udisks2.enable = true;
2024-04-26 10:25:17 +02:00
2024-05-11 22:55:59 +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"
'';
2024-04-26 10:25:17 +02:00
2024-05-11 22:55:59 +02:00
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-05-07 23:31:41 +02:00
2024-05-11 22:55:59 +02:00
boot = {
kernelParams = [ "quiet" ];
loader.efi.canTouchEfiVariables = true;
initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"nvme"
"usbhid"
"usb_storage"
"sd_mod"
];
2024-09-08 21:05:56 +02:00
# initrd.systemd.enable = true;
2024-05-11 22:55:59 +02:00
loader.systemd-boot.enable = true;
2024-05-29 09:47:17 +02:00
# extraModulePackages = [ config.boot.kernelPackages.ddcci-driver ];
2024-05-11 22:55:59 +02:00
kernelModules = [
"ddcci_backlight"
"i2c-dev"
"ec_sys"
];
2024-04-18 21:16:40 +02:00
};
2024-05-11 22:55:59 +02:00
};
2024-04-18 21:16:40 +02:00
options.grimmShared.laptop_hardware = {
enable = lib.mkEnableOption "grimm-laptop";
};
}