mirror of
https://github.com/donovanglover/nix-config.git
synced 2024-11-22 16:23:57 +01:00
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:
parent
941ef546e5
commit
a18125eaf9
@ -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;
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
@ -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 ];
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user