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; imports = builtins.attrValues self.nixosModules;
home-manager.sharedModules = builtins.attrValues self.homeManagerModules; home-manager.sharedModules = builtins.attrValues self.homeManagerModules;
environment.systemPackages = builtins.attrValues self.packages.x86_64-linux; 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, ... }: { pkgs, config, lib, ... }:
let let
inherit (lib) mkEnableOption; inherit (lib) mkEnableOption mkIf;
inherit (pkgs) piper; inherit (pkgs) piper;
cfg = config.modules.hardware; cfg = config.modules.hardware;
in in
{ {
options.modules.hardware = { options.modules.hardware = {
enable = mkEnableOption "hardware-specific configuration"; mouseSettings = mkEnableOption "piper for gaming mice";
mouseSettings = mkEnableOption "piper for mouse settings"; disableLaptopKeyboard = mkEnableOption "udev rule to disable laptop keyboard";
laptopKeyboard = mkEnableOption "laptop keyboard"; lidIgnore = mkEnableOption "ignoring the laptop lid on close";
lidIgnore = mkEnableOption "lid switch to standby"; powerIgnore = mkEnableOption "ignoring the power button on press";
powerIgnore = mkEnableOption "ignoring the power key";
}; };
# TODO: lib.mkIf cfg.enable config = with cfg; {
config = { services = {
services.ratbagd.enable = true; ratbagd.enable = mkIf mouseSettings true;
environment.systemPackages = [ piper ];
services.udev.extraRules = '' udev.extraRules = mkIf disableLaptopKeyboard ''
KERNEL=="event*", ATTRS{name}=="AT Translated Set 2 keyboard", ENV{LIBINPUT_IGNORE_DEVICE}="1" KERNEL=="event*", ATTRS{name}=="AT Translated Set 2 keyboard", ENV{LIBINPUT_IGNORE_DEVICE}="1"
''; '';
services.logind = { logind = {
lidSwitch = "ignore"; lidSwitch = mkIf lidIgnore "ignore";
extraConfig = "HandlePowerKey=ignore"; extraConfig = mkIf powerIgnore "HandlePowerKey=ignore";
}; };
}; };
environment.systemPackages = mkIf mouseSettings [ piper ];
};
} }