1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{ config, lib, pkgs, ... }:

let
  cfg = config.profpatsch.services.profpatsch.hardware.externalMonitorControl;

in {
    options.profpatsch.services.profpatsch.hardware.externalMonitorControl = {
        enable = lib.mkEnableOption "Enable external monitor control kernel modules & ddcutil";
    };

    config = lib.mkIf cfg.enable {

        boot.extraModulePackages = [
        # Allows controlling the hardware brightness of external monitors
        config.boot.kernelPackages.ddcci-driver
        ];
        boot.kernelModules = [
        "ddcci"
        "ddcci-backlight"
        "i2c_dev"
        ];
        # install the ddcutil package, gives users access to the monitor settings (brightness) via `uaccess`
        services.udev.packages = [ pkgs.ddcutil ];
        environment.systemPackages = [ pkgs.ddcutil ];

    };
}