meta: Use mkIf for hardware-specific config

Should make it easier to use this config without pulling in
the hardware-specific stuff.
This commit is contained in:
Donovan Glover 2024-04-04 00:25:01 -04:00
parent 941ef546e5
commit a18125eaf9
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 23 additions and 16 deletions

View File

@ -56,6 +56,12 @@
imports = builtins.attrValues self.nixosModules;
home-manager.sharedModules = builtins.attrValues self.homeManagerModules;
environment.systemPackages = builtins.attrValues self.packages.x86_64-linux;
modules.hardware = {
disableLaptopKeyboard = true;
lidIgnore = true;
powerIgnore = true;
};
}
];
};

View File

@ -1,32 +1,33 @@
{ pkgs, config, lib, ... }:
let
inherit (lib) mkEnableOption;
inherit (lib) mkEnableOption mkIf;
inherit (pkgs) piper;
cfg = config.modules.hardware;
in
{
options.modules.hardware = {
enable = mkEnableOption "hardware-specific configuration";
mouseSettings = mkEnableOption "piper for mouse settings";
laptopKeyboard = mkEnableOption "laptop keyboard";
lidIgnore = mkEnableOption "lid switch to standby";
powerIgnore = mkEnableOption "ignoring the power key";
mouseSettings = mkEnableOption "piper for gaming mice";
disableLaptopKeyboard = mkEnableOption "udev rule to disable laptop keyboard";
lidIgnore = mkEnableOption "ignoring the laptop lid on close";
powerIgnore = mkEnableOption "ignoring the power button on press";
};
# TODO: lib.mkIf cfg.enable
config = {
services.ratbagd.enable = true;
environment.systemPackages = [ piper ];
config = with cfg; {
services = {
ratbagd.enable = mkIf mouseSettings true;
services.udev.extraRules = ''
udev.extraRules = mkIf disableLaptopKeyboard ''
KERNEL=="event*", ATTRS{name}=="AT Translated Set 2 keyboard", ENV{LIBINPUT_IGNORE_DEVICE}="1"
'';
services.logind = {
lidSwitch = "ignore";
extraConfig = "HandlePowerKey=ignore";
logind = {
lidSwitch = mkIf lidIgnore "ignore";
extraConfig = mkIf powerIgnore "HandlePowerKey=ignore";
};
};
environment.systemPackages = mkIf mouseSettings [ piper ];
};
}